Fix shutdown hook