Added graceful shutdown hook