threading code needs some refactoring. List of changes:
* Script threads no longer call the debugger UI (e.g. refresh) nor do
they call the script system's cleanup function
(deleteStoppedInstances).
* Changed API.js Server.on method to queue calls to nativeAccept if .listen()
hasn't been called yet (otherwise winsock gives errors).
* Added various paranoia thread locks.
* Forced termination of script threads now works. The (commented) call
to TerminateThread didn't work because getCurrentThread() doesn't return
a "real" HANDLE. The solution is to pass the result of getCurrentThread
to DuplicateHandle to get a "real" handle.