BetterTouchTool Automations: Red Window Button Error

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

your script is buggy (or just not suited for being used like this), this is not a bug in BTT.

If BTT shows a menu instead of executing the action it means that you have defined the trigger twice. Probably you have added an app specific trigger for Edge.

Thank you for your prompt response as well as your advice for solving the problem for Microsoft Edge. Thanks to your advice the menu problem is solved, but clicking on Red Window Button in Microsoft edge still closes tabs instead of the window. Also, Red Window Button does not work at all after quitting BetterTouchTool (e.g. if BTT crashes). Could you advise in solving it?

Also, it would be great if you could advise on improving the Apple Script for quitting the app after the last open window is closed. It would be so practical for those who suffer from the physical system memory extreme limitations in modern MacBooks as well as immigrants from other operating systems.

P.S.: Would it be possible for you to add the useful feature of "Quit the app after the last open window is closed" to BTT?

Thank you again