Index: /trunk/src/VBox/Additions/x11/VBoxClient/seamless.cpp
===================================================================
--- /trunk/src/VBox/Additions/x11/VBoxClient/seamless.cpp	(revision 50372)
+++ /trunk/src/VBox/Additions/x11/VBoxClient/seamless.cpp	(revision 50373)
@@ -63,4 +63,11 @@
         rc = VERR_INTERNAL_ERROR;
         if (mHostEventThread)  /* Assertion */
+            break;
+        pszStage = "Testing event loop cancellation";
+        VbglR3InterruptEventWaits();
+        if (RT_FAILURE(VbglR3WaitEvent(VMMDEV_EVENT_VALID_EVENT_MASK, 0, NULL)))
+            break;
+        if (   VbglR3WaitEvent(VMMDEV_EVENT_VALID_EVENT_MASK, 0, NULL)
+            != VERR_TIMEOUT)
             break;
         pszStage = "Connecting to the X server";
@@ -221,16 +228,6 @@
 
     LogRelFlowFunc(("\n"));
-    /**
-     * @todo is this reasonable?  If the thread is in the event loop then the cancelEvent()
-     *       will cause it to exit.  If it enters or exits the event loop it will also
-     *       notice that we wish it to exit.  And if it is somewhere in-between, the
-     *       yield() should give it time to get to one of places mentioned above.
-     */
     mHostEventThreadStopping = true;
-    for (int i = 0; (i < 5) && mHostEventThreadRunning; ++i)
-    {
-        cancelEvent();
-        RTThreadYield();
-    }
+    cancelEvent();
     rc = RTThreadWait(mHostEventThread, RT_INDEFINITE_WAIT, NULL);
     if (RT_SUCCESS(rc))
Index: /trunk/src/VBox/Additions/x11/VBoxClient/testcase/tstSeamlessX11.cpp
===================================================================
--- /trunk/src/VBox/Additions/x11/VBoxClient/testcase/tstSeamlessX11.cpp	(revision 50372)
+++ /trunk/src/VBox/Additions/x11/VBoxClient/testcase/tstSeamlessX11.cpp	(revision 50373)
@@ -63,12 +63,11 @@
     }
     else
-    {
         rc = RTSemEventWait(eventSem, RT_INDEFINITE_WAIT);
-        if (RT_SUCCESS(rc))
-        {
-            rc = VERR_INTERRUPTED;
-        }
-    }
     return rc;
+}
+
+int VbglR3WaitEvent(uint32_t , uint32_t cMillies, uint32_t *)
+{
+    return RTSemEventWait(eventSem, cMillies);
 }
 
