1. Open the webChat.js file.
2. Locate the setupWebChat function.
3. Change the window.onbeforeunload function to the following:
    window.onbeforeunload = function() {
        // Some browsers appear to have issues around closing the CoBrowse session during page refresh
        // This appears to be low-level browser and/or network issues, so the best we can do is prevent the user from accidentally closing it
        var inCobrowse = coBrowse.getSessionItem(coBrowse.inCoBrowse);
        if (webChat.initCalled || inCobrowse === "true") {
            chatSocket.setupRefresh();
            return "You're about to end your session, are you sure?";
        }
    };
4. Change the window.onunload function to the following:
    window.onunload = function() {
        if (coBrowse !== 'undefined') {
            // reset the session details. This would normally be handled by a successful call to the logout method,
            // but some browsers have issues with the timing of this
            coBrowse.setSessionItem(coBrowse.inCoBrowse, "false");
            coBrowse.stopSession();
            return "Ending session";
        }
    };