AppleScript to close all applications

I used to have an automator workflow to close all applications which worked in Mojave and was very convenient but no longer in Catalina.
Could you suggest where I could find such a script for Catalina ?
thanks in advance for your time and help

I have this script and it works in Mojave. I don’t have a Mac that runs Catalina, so I can’t check if it works there also.

tell application "System Events" to set quitapps to name of every application process whose visible is true and name is not "Finder"
repeat with closeall in quitapps
	quit application closeall
end repeat
1 Like

very nice of you. thank you. I created a keyboard maestro macro to run the script.
Error message below
should there be an End tell at the end of something like that ?

thanks again very much

I tried end tell but does not work. thanks

Some troubleshooting: Is the above code the only code in your Execute AppleScript Action? Are there any other AppleScript Actions in your macro? What happens if you run it in Script Editor?

I just tested it with Keyboard Maestro. I copied the above script directly in the Execute ApleScript action and it worked fine in Mojave. You can also copy it in Script Editor and then save the script as a program (app) and then run this app with Keyboard Maestro.

I don’t know if there are any differences between the AppleScript versions of Mojave and Catalina, maybe.

If you are using Keyboard Maestro to trigger it, why not just use Keyboard Maestro’s Quit All Applications action?


I fell off my chair, and am quite embarrassed. Thanks VERY much !!

@evanfuchs @FrankV
thank you both for your suggestions.
There were no other AppleScript in my macro
keyboard maestro crashed
script editor worked except for closing script editor

In the end, @sylumer had the solution. keyboard maestro has a close all apps action. I am embarrassed and apologize to both of you for wasting your time.

Thanks again very much

No probleem. It is a good reminder for me to check the documentatie of Keyboard Maestro first, before trying to program something to solve a problem. Keyboard Maestro has so many features, I guess I use maybe 1% of it. :wink:

1 Like

It’s rather astounding and scary to think of all the keyboard maestro users, both the number of users and the number of times each user triggers macros every day, people whose workflow is dependant on those macros, and the fact that it is all dependant on one man, Peter Lewis, the developer, a genius.
I for one would suffer a rather brutal setup without KBM.

1 Like

This the AppleScript I use to close all applications.

– get list of open apps

tell application “System Events”

set allApps to displayed name of ( every process whose background only is false ) as list

end tell

– leave some apps open

set exclusions to {“Finder”, “Keyboard Maestro Engine”}

– quit each app

repeat with thisApp in allApps

set thisApp to thisApp as text

if thisApp is not in exclusions then

tell application thisApp to quit

end if

end repeat

I also have one for closing all Finder windows.

1 Like

thank you. It would be nice to have a subroutine

  • save and exit all windows for certain apps
  • do not save and close for other apps

For that, I’d use Keyboard Maestro. I love AppleScript and bash but I’m not the best at them so I fall back on Keyboard Maestro and its community.

1 Like

Sorry for the delay. Yes, I totally agree. thank you for your comment.