Deleting Persistent Records on module Shutdown

Hello,
I am developing a module that will monitor tags and publish their values into an HTTP API. Everything seems to be working fine except for one small detail: when I uninstall the module I can't seem to find a way to delete all the persistent records and associated Listeners that I created. The side effect is some of the logic I created to poll tags keeps polling them even after uninstall. Any help or example on how to delete all the records and also tables if possible would be very helpful.

Your gateway hook instance gets .shutdown() called when uninstalling. Use that. General practice is to not delete the records, just to unregister listeners. That pattern is required for module upgrade to run properly.

Thanks, I realized that I was actually missing two different things. The module can monitor tags in two different ways: 1) using the TagChangeListeners to publish when the value change and 2) using context.getExecutionManager().register() to publish based on fixed rate.
So I needed not only to unsubscribe all my listeners but also unregister and shutdown the ExecutionManager.