socket.onclose = function()

in lib/main.js [512:525]


    socket.onclose = function (closeEvent) {
        micStream.stop();

        // the close event immediately follows the error event; only handle one.
        if (!socketError && !transcribeException) {
            if (closeEvent.code != 1000) {
                showError(
                    "</i><strong>Streaming Exception</strong><br>" +
                        closeEvent.reason
                );
                toggleStartStop();
            }
        }
    };