The problem with the shutdown hook was that you have to exit the program rather than just stop it