On macOS, clicking the red close button closes the last Firefox window but does not quit Firefox. The application remains active in the Dock. This matters when Firefox is set to always use Private Browsing or to clear cookies and cache on shutdown: reopening a window can reuse the same session, while choosing Quit Firefox or pressing Command+Q ends it and runs the cleanup. Mozilla documents this macOS behavior in bug 1869987.
Quit Firefox when its last window closes
Hammerspoon can watch Firefox windows and request a normal quit when none remain:
- Install Hammerspoon, grant it Accessibility permission, and enable Launch Hammerspoon at login.
- Open
~/.hammerspoon/init.luaand add the following code. - From the Hammerspoon menu, choose Reload Config.
local firefoxBundleID = "org.mozilla.firefox"
firefoxWindowFilter = hs.window.filter.new(false)
:setAppFilter("Firefox", {})
local function cancelPendingFirefoxQuit()
if firefoxQuitTimer then
firefoxQuitTimer:stop()
firefoxQuitTimer = nil
end
end
firefoxWindowFilter:subscribe(
hs.window.filter.hasWindow,
cancelPendingFirefoxQuit
)
firefoxWindowFilter:subscribe(
hs.window.filter.hasNoWindows,
function()
cancelPendingFirefoxQuit()
firefoxQuitTimer = hs.timer.doAfter(1, function()
firefoxQuitTimer = nil
local firefox = hs.application.get(firefoxBundleID)
if firefox and #firefoxWindowFilter:getWindows() == 0 then
firefox:kill()
end
end)
end
)Now close Firefox with the red button. About one second after the final window closes, the Dock indicator should disappear. Firefox will stay open if another window is minimized, hidden, or located in another Space. The script requests a graceful quit; it does not force-kill the application.
To undo the change, remove this block from init.lua and reload the Hammerspoon configuration.
(September 4, 2026)