Index: /trunk/ccl/lisp-kernel/constants.h
===================================================================
--- /trunk/ccl/lisp-kernel/constants.h	(revision 453)
+++ /trunk/ccl/lisp-kernel/constants.h	(revision 454)
@@ -503,4 +503,5 @@
 #define TCR_FLAG_BIT_FOREIGN fixnumshift
 #define TCR_FLAG_BIT_AWAITING_PRESET (fixnumshift+1)
+#define TCR_FLAG_BIT_SHUTDOWN_REQUEST (fixnumshift+2)
 
 #define TCR_STATE_FOREIGN (1)
Index: /trunk/ccl/lisp-kernel/thread_manager.c
===================================================================
--- /trunk/ccl/lisp-kernel/thread_manager.c	(revision 453)
+++ /trunk/ccl/lisp-kernel/thread_manager.c	(revision 454)
@@ -456,28 +456,35 @@
   }
   
+  if (tcr->flags & (1<<TCR_FLAG_BIT_SHUTDOWN_REQUEST)) {
+    tcr->flags &= ~(1<<TCR_FLAG_BIT_SHUTDOWN_REQUEST);
+
 #ifdef DARWIN
-  darwin_exception_cleanup(tcr);
-#endif
-  
-  vs = tcr->vs_area;
-  tcr->vs_area = NULL;
-  ts = tcr->ts_area;
-  tcr->ts_area = NULL;
-  cs = tcr->cs_area;
-  tcr->cs_area = NULL;
-  if (vs) {
-    condemn_area(vs);
-  }
-  if (ts) {
-    condemn_area(ts);
-  }
-  if (cs) {
-    condemn_area(cs);
-  }
-  destroy_semaphore(&tcr->suspend);
-  destroy_semaphore(&tcr->resume);
-  destroy_semaphore(&tcr->reset_completion);
-  destroy_semaphore(&tcr->activate);
-  tcr->osid = 0;
+    darwin_exception_cleanup(tcr);
+#endif
+  
+    vs = tcr->vs_area;
+    tcr->vs_area = NULL;
+    ts = tcr->ts_area;
+    tcr->ts_area = NULL;
+    cs = tcr->cs_area;
+    tcr->cs_area = NULL;
+    if (vs) {
+      condemn_area(vs);
+    }
+    if (ts) {
+      condemn_area(ts);
+    }
+    if (cs) {
+      condemn_area(cs);
+    }
+    destroy_semaphore(&tcr->suspend);
+    destroy_semaphore(&tcr->resume);
+    destroy_semaphore(&tcr->reset_completion);
+    destroy_semaphore(&tcr->activate);
+    tcr->osid = 0;
+  } else {
+    tcr->flags |= (1<<TCR_FLAG_BIT_SHUTDOWN_REQUEST);
+    tsd_set(lisp_global(TCR_KEY), tcr);
+  }
 }
 
