Add per-mainloop shutdown hooks, and re-use the ShutdownListener for it.