title: uWSGI run on exit
body: <p>I'm running a Flask app via uWSGI. I have some cleanup code that I need to run when my app exits (to shut down some external processes). I installed signal handlers for <code>SIGTERM</code> and <code>SIGINT</code> to run the script using the python <code>signal</code> module. These work when I just run the app using <code>python</code> and hit for example <code>Ctrl+C</code>. However, for whatever reason, these don't get run when I do <code>/etc/init.d/uwsgi-emperor stop</code>, so they must be being bypassed by uWSGI code. What's the best way to get a function to be run on exit?</p>