window.addEventListener(\'unload\', function(e)
{
MyClass.shutdown();
window.removeEventListener(\'unload\', /* how to refer to this function? */);
}, false);
>
Name your function.
function f(e) {
MyClass.shutdown();
window.removeEventListener('unload', f);
}
window.addEventListener('unload', f, false);
Edit I think this will work too. Good point Kobi!
window.addEventListener('unload', function f(e)
{
MyClass.shutdown();
window.removeEventListener('unload', f);
}, false);