Index: /trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxClipboard.cpp
===================================================================
--- /trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxClipboard.cpp	(revision 61907)
+++ /trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxClipboard.cpp	(revision 61908)
@@ -659,4 +659,15 @@
         } break;
 
+        case WM_DESTROY:
+        {
+            vboxClipboardRemoveFromCBChain(pCtx);
+            if (pCtx->timerRefresh)
+                KillTimer(pCtx->hwnd, 0);
+            /* 
+             * don't need to call PostQuitMessage cause
+             * the VBoxTray already finished a message loop 
+             */
+        } break;
+
         default:
         {
@@ -732,8 +743,4 @@
     if (pCtx->hwnd)
     {
-        vboxClipboardRemoveFromCBChain(pCtx);
-        if (pCtx->timerRefresh)
-            KillTimer(pCtx->hwnd, 0);
-
         DestroyWindow(pCtx->hwnd);
         pCtx->hwnd = NULL;
Index: /trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDnD.cpp
===================================================================
--- /trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDnD.cpp	(revision 61907)
+++ /trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDnD.cpp	(revision 61908)
@@ -289,9 +289,11 @@
         {
             MSG uMsg;
-            while (GetMessage(&uMsg, 0, 0, 0))
+            BOOL fRet;
+            while ((fRet = GetMessage(&uMsg, 0, 0, 0)) > 0)
             {
                 TranslateMessage(&uMsg);
                 DispatchMessage(&uMsg);
             }
+            Assert(fRet >= 0);
 
             if (ASMAtomicReadBool(&pCtx->fShutdown))
Index: /trunk/src/VBox/HostServices/SharedClipboard/VBoxClipboard-win.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedClipboard/VBoxClipboard-win.cpp	(revision 61907)
+++ /trunk/src/VBox/HostServices/SharedClipboard/VBoxClipboard-win.cpp	(revision 61908)
@@ -62,5 +62,4 @@
 
     RTTHREAD thread;
-    bool volatile fTerminate;
 
     HANDLE hRenderEvent;
@@ -649,7 +648,12 @@
         } break;
 
-        case WM_CLOSE:
-        {
-            /* Do nothing. Ignore the message. */
+        case WM_DESTROY:
+        {
+            /* MS recommends to remove from Clipboard chain in this callback */
+            Assert(pCtx->hwnd);
+            removeFromCBChain(pCtx);
+            if (pCtx->timerRefresh)
+                KillTimer(pCtx->hwnd, 0);
+            PostQuitMessage(0);
         } break;
 
@@ -716,21 +720,21 @@
 
             MSG msg;
-            while (GetMessage(&msg, NULL, 0, 0) && !pCtx->fTerminate)
+            BOOL msgret = 0;
+            while ((msgret = GetMessage(&msg, NULL, 0, 0)) > 0)
             {
                 TranslateMessage(&msg);
                 DispatchMessage(&msg);
             }
-        }
-    }
-
-    if (pCtx->hwnd)
-    {
-        removeFromCBChain(pCtx);
-        if (pCtx->timerRefresh)
-            KillTimer(pCtx->hwnd, 0);
-
-        DestroyWindow (pCtx->hwnd);
-        pCtx->hwnd = NULL;
-    }
+            /* 
+            * Window procedure can return error, 
+            * but this is exceptional situation 
+            * that should be identified in testing
+            */
+            Assert(msgret >= 0);
+            Log(("VBoxClipboardThread Message loop finished. GetMessage returned %d, message id: %d \n", msgret, msg.message));
+        }
+    }
+
+    pCtx->hwnd = NULL;
 
     if (atomWindowClass != 0)
@@ -772,10 +776,7 @@
     Log(("vboxClipboardDestroy\n"));
 
-    /* Set the termination flag and ping the window thread. */
-    ASMAtomicWriteBool (&g_ctx.fTerminate, true);
-
     if (g_ctx.hwnd)
     {
-        PostMessage (g_ctx.hwnd, WM_CLOSE, 0, 0);
+        int rc = PostMessage (g_ctx.hwnd, WM_CLOSE, 0, 0);
     }
 
Index: /trunk/src/VBox/Main/src-server/win/HostPowerWin.cpp
===================================================================
--- /trunk/src/VBox/Main/src-server/win/HostPowerWin.cpp	(revision 61907)
+++ /trunk/src/VBox/Main/src-server/win/HostPowerWin.cpp	(revision 61908)
@@ -54,8 +54,6 @@
         Log(("HostPowerServiceWin::!HostPowerServiceWin: destroy window %x\n", mHwnd));
 
-        /* Is this allowed from another thread? */
-        SetWindowLongPtr(mHwnd, 0, 0);
         /* Poke the thread out of the event loop and wait for it to clean up. */
-        PostMessage(mHwnd, WM_QUIT, 0, 0);
+        PostMessage(mHwnd, WM_CLOSE, 0, 0);
         RTThreadWait(mThread, 5000, NULL);
         mThread = NIL_RTTHREAD;
@@ -117,23 +115,19 @@
             MSG msg;
             BOOL fRet;
-            while ((fRet = GetMessage(&msg, NULL, 0, 0)) != 0)
+            while ((fRet = GetMessage(&msg, NULL, 0, 0)) > 0)
             {
-                if (fRet != -1)
-                {
-                    TranslateMessage(&msg);
-                    DispatchMessage(&msg);
-                }
-                else
-                {
-                    // handle the error and possibly exit
-                    break;
-                }
+                TranslateMessage(&msg);
+                DispatchMessage(&msg);
             }
+            /*
+            * Window procedure can return error,
+            * but this is exceptional situation
+            * that should be identified in testing
+            */
+            Assert(fRet >= 0);
         }
     }
 
     Log(("HostPowerServiceWin::NotificationThread: exit thread\n"));
-    if (hwnd)
-        DestroyWindow(hwnd);
 
     if (atomWindowClass != 0)
@@ -214,4 +208,12 @@
         }
 
+        case WM_DESTROY:
+        {
+            /* moved here. it can't work across theads */
+            SetWindowLongPtr(hwnd, 0, 0);
+            PostQuitMessage(0);
+            return 0;
+        } 
+
         default:
             return DefWindowProc(hwnd, msg, wParam, lParam);
