Disconnect socket before page close.