Preview div, close socket on unload