using a synchronized shutdown hook