Improve the event handling at server shutdown
The event handling caused unhandled exception when shutting down the server when a real core was connected.
These changes together with TODO should fix these issues.
The event handling caused unhandled exception when shutting down the server when a real core was connected.
These changes together with TODO should fix these issues.