properly quit the scripting thread
connect to the kernel and call quit