Added: disconnect sockets before unloading the page.