Index: trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp	(revision 88780)
+++ trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp	(revision 88785)
@@ -1627,4 +1627,11 @@
 
     /* Create the soft keyboard only once: */
+    if (!m_pSoftKeyboardDialog)
+    {
+        QWidget *pCenterWidget = windowManager().realParentWindow(activeMachineWindow());
+        m_pSoftKeyboardDialog = new UISoftKeyboard(0, uisession(), pCenterWidget, machine().GetName());
+        connect(m_pSoftKeyboardDialog, &UISoftKeyboard::sigClose, this, &UIMachineLogic::sltCloseSoftKeyboard);
+    }
+
     if (m_pSoftKeyboardDialog)
     {
@@ -1633,17 +1640,10 @@
         m_pSoftKeyboardDialog->setWindowState(m_pSoftKeyboardDialog->windowState() & ~Qt::WindowMinimized);
         m_pSoftKeyboardDialog->activateWindow();
-        return;
-    }
-    QWidget *pCenterWidget = windowManager().realParentWindow(activeMachineWindow());
-    m_pSoftKeyboardDialog = new UISoftKeyboard(0, uisession(), pCenterWidget, machine().GetName());
-    if (m_pSoftKeyboardDialog)
-    {
-        connect(m_pSoftKeyboardDialog, &QMainWindow::destroyed, this, &UIMachineLogic::sltSoftKeyboardClosed);
-        m_pSoftKeyboardDialog->show();
-    }
-}
-
-void UIMachineLogic::sltSoftKeyboardClosed()
-{
+    }
+}
+
+void UIMachineLogic::sltCloseSoftKeyboard()
+{
+    delete m_pSoftKeyboardDialog;
     m_pSoftKeyboardDialog = 0;
 }
@@ -2810,4 +2810,5 @@
     sltCloseFileManagerDialog();
     sltCloseVMInformationDialog();
+    sltCloseSoftKeyboard();
 }
 
Index: trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h	(revision 88780)
+++ trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h	(revision 88785)
@@ -268,5 +268,5 @@
     void sltShowKeyboardSettings();
     void sltShowSoftKeyboard();
-    void sltSoftKeyboardClosed();
+    void sltCloseSoftKeyboard();
     void sltToggleMouseIntegration(bool fEnabled);
     void sltTypeCAD();
Index: trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp	(revision 88780)
+++ trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp	(revision 88785)
@@ -3849,5 +3849,4 @@
 {
     setWindowTitle(QString("%1 - %2").arg(m_strMachineName).arg(tr("Soft Keyboard")));
-    setAttribute(Qt::WA_DeleteOnClose);
     prepareObjects();
     prepareConnections();
@@ -3888,15 +3887,16 @@
     {
         QString strJoinedString = strNameList.join("<br/>");
-        if (msgCenter().questionBinary(this, MessageType_Warning,
+        if (!msgCenter().questionBinary(this, MessageType_Warning,
                                        tr("<p>Following layouts are edited/copied but not saved:</p>%1"
                                           "<p>Closing this dialog will cause loosing the changes. Proceed?</p>").arg(strJoinedString),
                                        0 /* auto-confirm id */,
                                        "Ok", "Cancel"))
-            QMainWindowWithRestorableGeometryAndRetranslateUi::closeEvent(event);
-        else
+        {
             event->ignore();
-        return;
-    }
-    QMainWindowWithRestorableGeometryAndRetranslateUi::closeEvent(event);
+            return;
+        }
+    }
+    emit sigClose();
+    event->ignore();
 }
 
Index: trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.h
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.h	(revision 88780)
+++ trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.h	(revision 88785)
@@ -57,4 +57,5 @@
 
     void sigHelpRequested(const QString &strHelpKeyword);
+    void sigClose();
 
 public:
