Gracefully shutdown the agent on SIGTERM