title: Python Flask app not exiting with sys exit
body: <p>I'd like to be able to terminate my flask app remotely with an http request like this:</p>
  
  <pre><code>import flask
  import sys
  
  master = flask.Flask(__name__)
  
  @master.route('/shutdown')
  def shutdown():
      #do things
      sys.exit()
  
  if __name__ == '__main__':
      master.run()
  </code></pre>
  
  <p>Thing is it just doesn't work. From the terminal I get nothing, as if it's not even processing the request. I know that sys.exit() just raises a SystemExit, so I think it may be that it gets caught somewhere. The fact that os._exit(0) does work also leads me to think so.</p>
  
  <p>Am I tripping on something stupid? Is it actually a bug and there is a workaround? I'd prefer not to use os._exit(0) if possible. Thanks!</p>
  
  <p>Edit: I wouldn't say this question is a duplicate since the accepted answers differ and the other one is from '13 (Flask's gone a long way in the meantime)</p>