internal: unregister the events channel before closing it
defers are executed in oposite direction that then are called. If we call the close defer after the unregistration of the channel it will executed first. It can happen that an event arrive between the two of them and crash rdsys.
- Closes: #222