I am using Cherrypy framework for some simple REST based apps. IF the server is being closed down, either by the operator or by the OS, I want to be able to run a function to clean up the environmental setup for that session. In many cases you can do this on startup, by in this case there is hardware that I want to close down.
In the documentation I could not find anyway to catch a signal that the server is closing down and run some code