added support for close event

This PR includes the close event when a peer has closed the window or lost the connection.

:bowtie: