PingTimeout now causes disconnect, onsocketclose causes disconnect if it's independent of logout, and lock around disconnect to avoid race case from multiple events calling disconnect at the same time