var listener = { handleEvent : function(aEventItem) { switch (aEventItem.type) { case 'quit': if (!confirm('are you OK?')) aEventItem.preventDefault(); return; case 'unload': alert('OK, let's exit Firefox.'); Application.events.removeListener('quit', this); Application.events.removeListener('unload', this); return; } } }; Application.events.addListener('quit', listener); Application.events.addListener('unload', listener);