Add the graceful shutdown to API.