Frontend socket close support to avoid exceptions.

Frontend websocket close was not properly detected causing exception on following console.log through onBackendMessage.