cleanly close socket events