diff --git a/src/plugins/qmlinspector/qmlinspectorplugin.cpp b/src/plugins/qmlinspector/qmlinspectorplugin.cpp
index 5642682623b7ff1180971c2404b8519929e55b9c..29b993fa16402a5c0fd0e069e792b4fd8be90e92 100644
--- a/src/plugins/qmlinspector/qmlinspectorplugin.cpp
+++ b/src/plugins/qmlinspector/qmlinspectorplugin.cpp
@@ -79,13 +79,14 @@ QmlInspectorPlugin::QmlInspectorPlugin()
 
 QmlInspectorPlugin::~QmlInspectorPlugin()
 {
+    removeObject(m_inspector);
+    delete m_inspector;
+    m_inspector = 0;
 }
 
 void QmlInspectorPlugin::shutdown()
 {
-    removeObject(m_inspector);
-    delete m_inspector;
-    m_inspector = 0;
+
 }
 
 bool QmlInspectorPlugin::initialize(const QStringList &arguments, QString *errorString)