diff -Naur tk8.6.5-orig/generic/tkEvent.c tk8.6.5/generic/tkEvent.c
--- tk8.6.5-orig/generic/tkEvent.c	2016-02-16 21:21:01.000000000 +0300
+++ tk8.6.5/generic/tkEvent.c	2016-03-03 09:21:53.281037200 +0300
@@ -2017,7 +2017,16 @@
     }
 #endif
 
-    Tcl_DeleteExitHandler(TkFinalize, NULL);
+    /* There's no guarantee that Tcl_InitStubs
+     * has been called before exit; tclStubsPtr
+     * is NULL in this case.
+     */
+#if defined(USE_TCL_STUBS)
+    if (tclStubsPtr == NULL)
+	    return;
+#endif
+
+	Tcl_DeleteExitHandler(TkFinalize, NULL);
 
     Tcl_MutexLock(&exitMutex);
     for (exitPtr = firstExitPtr; exitPtr != NULL; exitPtr = firstExitPtr) {
