The function removeChild throws an exception when the element specified doesn't exist. This can happen when opening the websocket throws an exception during connect. Fixes issue #979