Please allow application to quit when last window is closed

Using this method led to the following bug (Reported here). What is your advice?

Describe the bug
Red Window Button does not properly after defining Automations & Named & Other Triggers:

  1. Red Window Button does not work at all after quitting BetterTouchTool (e.g., BTT crashes and closed automatically)
  2. Clicking on Red Window Button in an app, randomly closes other apps' windows!
  3. Clicking on Red Window Button in web browsers' private/incognito windows closes tabs instead windows!
  4. Clicking on Red Window Button in Microsoft Edge shows a menu instead of closing the window!

Screenshots
Clicking on Red Window Button in the Activity Monitor app closes Firefox! (Note: Activity Monitor is the active window):

Clicking on Red Window Button in Microsoft Edge shows a menu instead of closing the window:
image

Device information:

  • Type of Mac: MacBook Air M1
  • macOS version: 12.6.3 (21G419)
  • BetterTouchTool version: 4.023 (2240)

Additional information:
The following Apple Script is defined to run when clicking on Red Window Button based on this topic:

tell application "System Events"
    set activeProcesses to first process where it is frontmost
	
    repeat with theProcess in activeProcesses
        if not background only of theProcess then
		
            tell theProcess
                set processName to name
                set theWindows to windows
            end tell
			
            set windowsCount to count of theWindows
        end if
    end repeat
end tell

if windowsCount is less than or equal to 1 then
	tell application (get path to frontmost application as text)
		quit
	end tell
else
	tell application "System Events"
		keystroke "w" using command down
	end tell
end if

1 Like