Index: /trunk/source/level-1/l1-processes.lisp
===================================================================
--- /trunk/source/level-1/l1-processes.lisp	(revision 13635)
+++ /trunk/source/level-1/l1-processes.lisp	(revision 13636)
@@ -639,17 +639,21 @@
     (with-standard-abort-handling "Exit Lisp"
       (prepare-to-quit)
-      ;; We may have abruptly terminated a thread
-      ;; which owned the output lock on *STDOUT*.
-      ;; Don't block waiting on that lock if so.
-      (let* ((s *stdout*)
-	     (lock (ioblock-outbuf-lock (basic-stream-ioblock s)))
-	     (locked (make-lock-acquisition)))
-	(declare (dynamic-extent locked))
-	(when (or (null lock) (%try-recursive-lock-object lock locked))
-	  (unwind-protect
-	       (progn
-		 (fresh-line s)
-		 (finish-output s)))
-	  (when (lock-acquisition.status locked) (release-lock lock)))))
+      ;; We may have abruptly terminated a thread which owned the
+      ;; output lock on a stream we want to flush.  Don't block
+      ;; waiting on the lock if so.
+      (flet ((flush-stream (s)
+	       (let* ((lock (ioblock-outbuf-lock (basic-stream-ioblock s)))
+		      (locked (make-lock-acquisition)))
+		 (declare (dynamic-extent locked))
+		 (when (or (null lock)
+			   (%try-recursive-lock-object lock locked))
+		   (unwind-protect
+			(progn
+			  (fresh-line s)
+			  (finish-output s))
+		     (when (lock-acquisition.status locked)
+		       (release-lock lock)))))))
+	(flush-stream *stdout*)
+	(flush-stream *stderr*)))
     (%set-toplevel thunk)
     (toplevel)))
