Add close event for sockets