Wrap the onbeforeunload disconnect in a try/catch so we don't fail in the case of no internet connection.