Close the socket and reset connection specific data.
Finally, emit reason channel_event on main context if not NONE.
reason
a Channel
a channel event emitted on main context (or NONE)