Cubase hanging on exit

I’m actively working on a MIDI Remote driver. Periodically Cubase is hanging on exit and I have to kill it manually or restart. Seems to happen more frequently with the latest update but could be coincidence.
One thing I’m wondering: When exiting Cubase, are all of the callbacks from the remote API being stopped prior to attempting to stop/unload the driver?
Are there any steps I should take in the driver to detect Cubase is quitting and stop the callbacks in my driver?
Note that this may be totally unrelated, but it crossed my mind as a potential problem if the callback hooks are still be called when the driver is unloaded.