Setting disconnected = true prior to firing disconnect event, to avoid sc

Setting disconnected = true prior to firing disconnect event, to avoid scenario where socket disconnected is set to false inside disconnect event.

Should fix #483, although not tested.