Add OnClose handler to close remote connection