Logic for application that want use beforeunload event for unsubscribing - Atmosphere/atmosphere GitHub Wiki

By default, Atmosphere is using the unload event to unsubscribe and close its associated connection. If you want to do the same with beforeUnload, just do:

Logic for those who want use beforeunload event
$(window).on("beforeunload", function() {
    $(window).trigger("unload.atmosphere");
});