Index: /trunk/FACT++/src/InterpreterV8.cc
===================================================================
--- /trunk/FACT++/src/InterpreterV8.cc	(revision 14600)
+++ /trunk/FACT++/src/InterpreterV8.cc	(revision 14601)
@@ -38,6 +38,18 @@
 // ------------
 // Each thread running V8 code needs to be signalled individually for
-// termination.
+// termination. Therefor a list of V8 thread ids is created.
 //
+// If temrination has already be signalled, no thread should start running
+// anymore (thy could, e.g., wait for their locking). So after locking
+// it has to be checked if the thread was terminated already. Note
+// that all calls to Terminate() must be locked to ensure that fThreadId
+// is correct when it is checked.
+//
+// Empty handles:
+// --------------
+// If exceution is terminated, V8 calls might return with empty handles,
+// e.g. Date::New(). Therefore, the returned handles of these calls have to
+// be checked in all placed to avoid that V8 will core dump.
+//
 
 // ==========================================================================
@@ -47,14 +59,16 @@
 void InterpreterV8::Terminate()
 {
-    /*
+    if (!Locker::IsLocked())
+        JsException("***** InterprterV8::Terminate call not locked *****");
+
     for (auto it=fThreadIds.begin(); it!=fThreadIds.end(); it++)
         V8::TerminateExecution(*it);
     fThreadIds.clear();
-    */
-    if (fThreadId<0)
-        return;
-
-    V8::TerminateExecution(fThreadId);
-    fThreadId = -1;
+
+    if (fThreadId>=0)
+    {
+        V8::TerminateExecution(fThreadId);
+        fThreadId = -1;
+    }
 }
 
@@ -118,5 +132,5 @@
 
     const Handle<Script> sleep = Script::Compile(String::New(("dim.sleep("+to_string(ms)+");").c_str()));
-    if (!sleep.IsEmpty() && !sleep->Run().IsEmpty())
+    if (ms==0 || (!sleep.IsEmpty() && !sleep->Run().IsEmpty()))
     {
         Handle<Value> args[] = {  };
