catch shutdown errors
Catch erros during shutdown

- Do not remove defers not in list
- Do not try to stop a non-running loop.
Merge remote-tracking branch 'refs/remotes/kali/bug/catch-shutdown-errors' into develop