Disconnect from socket when window closes