Index: /branches/working-0711/ccl/level-1/l1-processes.lisp
===================================================================
--- /branches/working-0711/ccl/level-1/l1-processes.lisp	(revision 13138)
+++ /branches/working-0711/ccl/level-1/l1-processes.lisp	(revision 13139)
@@ -639,6 +639,17 @@
     (with-standard-abort-handling "Exit Lisp"
       (prepare-to-quit)
-      (fresh-line *stdout*)
-      (finish-output *stdout*))
+      ;; 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)))))
     (%set-toplevel thunk)
     (toplevel)))
