tweaks to script engine shutdown behavior
correct handleing of app shutdown and scripting enging termination