Improve close event -- don't kill JVM unless nothing else is running