Index: /trunk/src/VBox/Main/MachineImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/MachineImpl.cpp	(revision 30881)
+++ /trunk/src/VBox/Main/MachineImpl.cpp	(revision 30882)
@@ -9171,4 +9171,7 @@
 void Machine::registerMetrics(PerformanceCollector *aCollector, Machine *aMachine, RTPROCESS pid)
 {
+    AssertReturnVoid(isWriteLockOnCurrentThread());
+    AssertPtrReturnVoid(aCollector);
+
     pm::CollectorHAL *hal = aCollector->getHAL();
     /* Create sub metrics */
@@ -9287,9 +9290,17 @@
 void Machine::unregisterMetrics(PerformanceCollector *aCollector, Machine *aMachine)
 {
-    aCollector->unregisterMetricsFor(aMachine);
-    aCollector->unregisterBaseMetricsFor(aMachine);
+    AssertReturnVoid(isWriteLockOnCurrentThread());
+
+    if (aCollector)
+    {
+        aCollector->unregisterMetricsFor(aMachine);
+        aCollector->unregisterBaseMetricsFor(aMachine);
+    }
 
     if (mGuestHAL)
+    {
         delete mGuestHAL;
+        mGuestHAL = NULL;
+    }
 }
 
Index: /trunk/src/VBox/Main/VirtualBoxImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/VirtualBoxImpl.cpp	(revision 30881)
+++ /trunk/src/VBox/Main/VirtualBoxImpl.cpp	(revision 30882)
@@ -2723,5 +2723,8 @@
          * it done immediately. It reduces the number of locks needed and
          * the lock contention in SessionMachine::uninit. */
-        mMachine->unregisterMetrics(mVirtualBox->performanceCollector(), mMachine);
+        {
+            AutoWriteLock mLock(mMachine COMMA_LOCKVAL_SRC_POS);
+            mMachine->unregisterMetrics(mVirtualBox->performanceCollector(), mMachine);
+        }
 #endif /* VBOX_WITH_RESOURCE_USAGE_API */
 
