Add a shutdown hook