I was wondering if there is any way I can make Blender executes some python code just before it exits ?
In my case I want to disable an addon, such that blender does not try to enable it the next time it runs.
I tried using atexit.register() of course, but I get an error that makes me think Blender has already deallocated everything, so I have no more access to bpy.ops.preferences.addon_disable().
I have been thinking of using a handler (https://docs.blender.org/api/current/bpy.app.handlers.html) but none seems to fit my need.
Thanks for your answers.