Added synchronized window unload handler

if [syncDisconnectOnUnload], it handles the window onunload event 
and disconnects the websocket