Shutdown hook for addon

Hello, I have a multi-threaded addon. When I run Blender from the command line, run my addon, then exit Blender, the GUI closes but the process still runs. When I CTRL-C it exits fully with a “KeyboardInterrupt” exception. I have a call in my addon “unregister()” to shut down my threading work. When I disable the addon and then quit, it exits as desired.

Is there a method I can define in my addon that is called on exit? Is there an appropriate way to do this with Python alone? I couldn’t get the atexit module to help the situation.

Thanks.

/Daryl

there are hooks for saving and rendering, but if you want to catch the exit event all the time, then the answer is no I’m afraid. You could test the behavior of a python class however, whether its deconstructor method is called before shutdown…