Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp	(revision 29925)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp	(revision 29926)
@@ -102,4 +102,19 @@
 UIMachineWindow::~UIMachineWindow()
 {
+    /* Close any opened modal & popup widgets: */
+    while (QWidget *pWidget = QApplication::activeModalWidget() ? QApplication::activeModalWidget() :
+                              QApplication::activePopupWidget() ? QApplication::activePopupWidget() : 0)
+    {
+        /* Set modal/popup window's parent to null early,
+         * because deleteLater() is synchronous
+         * and will be called later than this destructor: */
+        pWidget->setParent(0);
+        /* Close modal/popup window early to hide it
+         * because deleteLater() is synchronous
+         * and will be called later than this destructor: */
+        pWidget->close();
+        /* Delete modal/popup window synchronously (safe): */
+        pWidget->deleteLater();
+    }
 }
 
