keeping taskchain on panda3d exit

Hello,
for my current project, i use pythons sqlite3 database for loading/saving of ingame objects, in an seperate thread to prevent the framerate from dropping every time a new object is loaded.
Unfortunately, sqlite db connections can only used by the thread they were created in, so the taskChain i use for saving levels may never be destroyed!
However, when the user closes the main window, the panda3d seems to shut down all threads, and base.finalExitCallbacks just allows me to use the main thread, making it impossible to close the database.

Does anybody have an idea of how to keep this taskChain for the cleanup when exiting panda3d?

thx for help,
laurin

ShowBase calls self.userExit() whenever it detects that the main window has been closed, the default implementation of which calls sys.exit().

The easiest way to get around this is if you’re inheriting from ShowBase by overriding the userExit method to do whatever you want.