Added graceful shutdown on both SIGINT and SIGTERM.