Tornado doesn't restart cleanly in supervisor
===

I'm using tornado to run a flask app, and I have a shell script which does a little work and then runs the app.

    #!/usr/bin/env bash
    some_work
    more_work
    python /usr/share/theapp/theapp.py

I use supervisor to manage this little script.  Starting up works fine (`sudo supervisorctl start theapp.sh`), but when I want to restart, the python subprocess doesn't exit and hangs around, occupying the port and preventing startup again. I've tried adding traps to ensure that the python code really is stopped when the script is stopped by supervisor, but this hasn't worked.  I've tried switching out tornado for gevent's wsgi server and have had the same problem.  How should I be doing this small script?