Frontend socket close support to avoid exceptions.

Frontend websocket close was not properly detected causing exception on following console.log through onBackendMessage.
Merge pull request #62 from marcominetti/master

Frontend socket close support to avoid exceptions.