Handle dis/reconnect and quit