App quits when last window is closed

Hi there, BTT gives the option to make the red button a “quit button” instead of a “close button.” The problem with that is, no matter how many windows you have open of the same app, the red button then quits all of the windows. Is there a way to have the red button close as usual, unless I am closing the last window of an app. Then the red button would quit the app, because no other windows are open. This would make Mac work like Windows (which I think makes a lot more sense personally). Thanks for any help!

I'm not sure if this'll help, but in macOS, ⌘W closes the frontmost window. ⌘Q quits an app, but some apps will ask about saving each window.
Some apps quit when the last window is closed. Others do not. That depends on whether it makes any sense to have the app open with no windows open. (Or at least that's the theory.)

Yeah thanks. I am aware of those shortcuts. Just seems like Mac should quit the app when the last window is closed. And BTT does attempt to help with this by giving you the ability to change the red button to quit. But it would be great if the red button could close as usual and quit when closing the last window.

Basically it’s the RedQuits app functionality that I was looking for in BTT. It’s just that Redquits is very inconsistent. Sometimes it works, sometimes it doesn’t.

I just tested the following: I created an Automator action and assigned a (complicated) keyboard shortcut (that is not used for anything else, of course) to this action (such as [cmd][opt][ctrl][shift][#]). The process is straightforward and described on

Inspired by,

I programmed the following in Automator:

on run {input, parameters}
	tell application "System Events"
		set activeApp to name of first application process whose frontmost is true
	end tell
		tell application activeApp
			set num_windows to (count (windows whose visible is true))
		end tell
		if num_windows > 0 then
			-- Debugging:
			-- display dialog activeApp & " has " & num_windows & " open windows."
			-- Debugging:
			-- display dialog activeApp & " has " & num_windows & " open windows."
			-- display dialog "Going to quit " & activeApp & "."
			tell application activeApp to quit
		end if
	end try
	return input
end run

I switched the logic of the if condition because, for instance, Microsoft Word delivers a missing value for the number of open windows and thus wouldn’t quit with num_windows == 0.

In BetterTouchTool, choose

(You don’t have to use right-clicking the red button, of course; you can also choose left-clicking.)

Upon first using this, macOS will ask you to grant access to the respective application to control “System Evens.”

A limitation is that this closes an application only if the window whose red button you click is in the front. (That is, for instance, closing the last window of Mail if Safari is the frontmost application will not quit Safari.)

1 Like