correctly destroy socket and protocol
fix browser detection, connection teardown