properly shut down library threads when cherrypy stops