diff --git a/src/threads.c b/src/threads.c
index 04e6dc2893456e91b128363338269316dd7254e7..94b9c399fae320988f55b0466c061c16c7db8e40 100644
--- a/src/threads.c
+++ b/src/threads.c
@@ -1206,6 +1206,9 @@ PMOD_EXPORT void call_with_interpreter(void (*func)(void *ctx), void *ctx)
     thread_obj = NULL;
     num_threads--;
     mt_unlock_interpreter();
+#ifdef PIKE_DEBUG
+    Pike_interpreter_pointer = NULL;
+#endif
   }
 }