providing api for deinit (worker process shutdown)

here are changes as requested to expose an api that can be used by celery, to avoid monkeypatching on_loop_stop

funny enough, after all this work, the other way feels cleaner, but I understand the value of abstraction barriers.