diff --git a/Code/Mantid/MantidQt/API/src/AlgorithmDialog.cpp b/Code/Mantid/MantidQt/API/src/AlgorithmDialog.cpp
index 5299ae1d04264346765f15520a23e745f6d02a38..872eb36f14b6e12ce189000182172f07fb4c64dc 100644
--- a/Code/Mantid/MantidQt/API/src/AlgorithmDialog.cpp
+++ b/Code/Mantid/MantidQt/API/src/AlgorithmDialog.cpp
@@ -1191,16 +1191,17 @@ void AlgorithmDialog::errorHandle(const IAlgorithm *alg, const std::string &what
  * Only allow close when close is enabled
  */
 void AlgorithmDialog::closeEvent(QCloseEvent *evt) {
-  if(m_exitButton->isEnabled()) {
-    evt->accept();
-  }
-  else {
-    evt->ignore();
+  if (m_exitButton) {
+    if (m_exitButton->isEnabled()) {
+      evt->accept();
+    } else {
+      evt->ignore();
+    }
+  } else {
+    QDialog::closeEvent(evt);
   }
 }
 
-
-
 /**Handle completion of algorithm started while staying open.
  * reenables the OK button when the algorithms finishes.
  *