Changed signal handler to work with standard Java shutdown hook