New thread.c from Sjoerd, supports _exit_prog().  Use this in goaway()
to avoid hanging in cleanup().
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 08d1dbe..5358ee5 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -361,6 +361,10 @@
 
 /* Clean up and exit */
 
+#ifdef USE_THREAD
+extern int threads_started;
+#endif
+
 void
 goaway(sts)
 	int sts;
@@ -375,7 +379,10 @@
 	
 	(void) save_thread();
 	donecalls();
-	exit_prog(sts);
+	if (threads_started)
+		_exit_prog(sts);
+	else
+		exit_prog(sts);
 	
 #else /* USE_THREAD */