diff --git a/src/plugins/debugger/cdb/cdbengine.cpp b/src/plugins/debugger/cdb/cdbengine.cpp
index 98ede2d10ebc4f1cff7c7bdc9f4673f9315360db..6198568435202a3b122f831a50c316a31265b37b 100644
--- a/src/plugins/debugger/cdb/cdbengine.cpp
+++ b/src/plugins/debugger/cdb/cdbengine.cpp
@@ -646,10 +646,10 @@ void CdbEnginePrivate::endDebugging(bool detachOnly)
     if (endSession(&errorMessage)) {
         STATE_DEBUG(Q_FUNC_INFO, __LINE__, "notifyEngineShutdownOk");
         m_engine->notifyEngineShutdownOk();
-        errorMessage = QString::fromLatin1("There were errors trying to end debugging:\n%1").arg(errorMessage);
-        m_engine->showMessage(errorMessage, LogError);
     } else {
         STATE_DEBUG(Q_FUNC_INFO, __LINE__, "notifyEngineShutdownFailed");
+        errorMessage = QString::fromLatin1("There were errors trying to end debugging:\n%1").arg(errorMessage);
+        m_engine->showMessage(errorMessage, LogError);
         m_engine->notifyEngineShutdownFailed();
     }
 }