Add a shutdown hook to gracefully terminate on ctrl+c