Index: /trunk/src/VBox/Runtime/common/misc/thread.cpp
===================================================================
--- /trunk/src/VBox/Runtime/common/misc/thread.cpp	(revision 66119)
+++ /trunk/src/VBox/Runtime/common/misc/thread.cpp	(revision 66120)
@@ -1166,8 +1166,21 @@
             if (pThread->fFlags & RTTHREADFLAGS_WAITABLE)
             {
-                if (fAutoResume)
-                    rc = RTSemEventMultiWait(pThread->EventTerminated, cMillies);
+#if defined(IN_RING3) && defined(RT_OS_WINDOWS)
+                if (RT_LIKELY(rtThreadNativeIsAliveKludge(pThread)))
+#endif
+                {
+                    if (fAutoResume)
+                        rc = RTSemEventMultiWait(pThread->EventTerminated, cMillies);
+                    else
+                        rc = RTSemEventMultiWaitNoResume(pThread->EventTerminated, cMillies);
+                }
+#if defined(IN_RING3) && defined(RT_OS_WINDOWS)
                 else
-                    rc = RTSemEventMultiWaitNoResume(pThread->EventTerminated, cMillies);
+                {
+                    rc = VINF_SUCCESS;
+                    if (pThread->rc == VERR_PROCESS_RUNNING)
+                        pThread->rc = VERR_THREAD_IS_DEAD;
+                }
+#endif
                 if (RT_SUCCESS(rc))
                 {
Index: /trunk/src/VBox/Runtime/include/internal/thread.h
===================================================================
--- /trunk/src/VBox/Runtime/include/internal/thread.h	(revision 66119)
+++ /trunk/src/VBox/Runtime/include/internal/thread.h	(revision 66120)
@@ -180,4 +180,19 @@
 DECLHIDDEN(void) rtThreadNativeDestroy(PRTTHREADINT pThread);
 
+#ifdef IN_RING3
+/**
+ * Called to check whether the thread is still alive or not before we start
+ * waiting.
+ *
+ * This is a kludge to deal with windows threads being killed wholesale in
+ * certain process termination scenarios and we don't want to hang the last
+ * thread because it's waiting on the semaphore of a dead thread.
+ *
+ * @returns true if alive, false if not.
+ * @param   pThread         The thread structure.
+ */
+DECLHIDDEN(bool) rtThreadNativeIsAliveKludge(PRTTHREADINT pThread);
+#endif
+
 #ifdef IN_RING0
 /**
Index: /trunk/src/VBox/Runtime/r3/win/thread-win.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r3/win/thread-win.cpp	(revision 66119)
+++ /trunk/src/VBox/Runtime/r3/win/thread-win.cpp	(revision 66120)
@@ -30,5 +30,5 @@
 *********************************************************************************************************************************/
 #define LOG_GROUP RTLOGGROUP_THREAD
-#include <iprt/win/windows.h>
+#include <iprt/nt/nt-and-windows.h>
 
 #include <errno.h>
@@ -279,4 +279,14 @@
 
 
+DECLHIDDEN(bool) rtThreadNativeIsAliveKludge(PRTTHREADINT pThread)
+{
+    PPEB_COMMON pPeb = NtCurrentPeb();
+    if (!pPeb || !pPeb->Ldr || !pPeb->Ldr->ShutdownInProgress)
+        return true;
+    DWORD rcWait = WaitForSingleObject((HANDLE)pThread->hThread, 0);
+    return rcWait != WAIT_OBJECT_0;
+}
+
+
 RTDECL(RTTHREAD) RTThreadSelf(void)
 {
