scheduler shutdown
diff --git a/scheduler/scheduler.cc b/scheduler/scheduler.cc
index 225e484..e7630d2 100644
--- a/scheduler/scheduler.cc
+++ b/scheduler/scheduler.cc
@@ -82,13 +82,13 @@
 void
 Scheduler::shutdown()
 {
+  WriteLock lock(m_mutex);
+  if (m_running)
   {
-    WriteLock lock(m_mutex);
+    event_base_loopbreak(m_base);
+    m_thread.join();
     m_running = false;
   }
-  
-  event_base_loopbreak(m_base);
-  m_thread.join();
 }
 
 bool