Index: /trunk/FACT++/src/dataLogger.cc
===================================================================
--- /trunk/FACT++/src/dataLogger.cc	(revision 10487)
+++ /trunk/FACT++/src/dataLogger.cc	(revision 10488)
@@ -1433,4 +1433,12 @@
 }
 
+void RunThread(DataLogger *logger)
+{
+    // This is necessary so that the StateMachien Thread can signal the
+    // Readline thread to exit
+    logger->Run(true);
+    Readline::Stop();
+}
+
 template<class T>
 int RunShell(Configuration &conf)
@@ -1446,11 +1454,16 @@
 
     DataLogger logger(wout);
-
     shell.SetReceiver(logger);
 
-    logger.SetReady();
-
-    shell.Run();                 // Run the shell
-     logger.SetNotReady();
+    boost::thread t(boost::bind(RunThread, &logger));
+
+    shell.Run();    // Run the shell
+
+    logger.Stop();  // Signal Loop-thread to stop
+
+    // Wait until the StateMachine has finished its thread
+    // before returning and destroying the dim objects which might
+    // still be in use.
+    t.join();
 
     return 0;
