Implemented app.run with graceful shutdown.