Killing All Running Applications

I am looking to use a hot key to kill all applications - different from Quit, in the sense that I would just want to kill all running programs that would show up in COMMAND/OPTION/ESCAPE. I am not looking for an elegant “quit” scenario where I am prompted whether I really want to close a given program that might be in the middle of something.

I see that “Close All Applications” is available, but there is no choice to “kill” the applications for that scenario (as far as I can tell).

I could write a KM macro to COMMAND?OPTION/ESCAPE, and then go through mouse movements and clicks to close apps. But I was hoping there might be something more elegant and to-the-point - either through something I am not seeing in KM, or maybe through Perl, Python, or some other command line code that I could roll into KM or Automator.

No, there is no Force Quit or Kill "All Applications.

There is a Force Quit variant of the Quit Application action, so you could use a sequence of these listing out all the apps you normally have running, and adding any as you notice any not being quit.

Note that it is generally a very bad idea to kill or force quit an application. The potential for loss of data is quite large - even previously “saved” data can become corrupted if you kill an application. It should only be used as a last resort, so “Force Quit All Applications” would almost always be a terrible idea.

Yes, I realize the potential for corruption, like yanking out a USB hard disk. But sometimes there are more than one app that are stuck in a related activity that just won’t resolve.

There are some other things I am looking at, that will provide a less violent exit, like cycling through simply quitting apps first.

Many thanks for the Reply.

You can do something like this with AppleScript:

tell application "System Events"
   set procList to name of every process whose background only is false
end tell
repeat with i in procList
   tell application i to quit without saving
end repeat

Although that’s not going to kill any stuck apps.

You can change without saving to with saving, although I don’t know offhand how Versions will work with this, because I haven’t messed with it since Snow Leopard (probably).

You can also use the shell and kill or killall with various signals. See the man page for each.

There’s also pkill which allows for killing apps with grep. It used to only be available if you’d installed Xcode, but I think maybe it’s stock on Mavericks. See the man page.

But. As Peter said. Caveat Emptor. Know what you’re doing.

-Chris

I don’t see a way to tell what apps are NOT background-only using the shell, but it can be done with easily enough with AppleScript. Then you can compose a shell script with the resulting PIDs and run that via AppleScript or with an Execute Shell Action in Keyboard Maestro.

tell application "System Events"
   set procIDList to unix id of every process whose background only is false
end tell
set AppleScript's text item delimiters to " "
set procIDList to procIDList as text
set shellCMD to "kill " & procIDList

# Uncomment the following line to run the command.  (KNOW WHAT YOU ARE DOING!)
# do shell script shellCMD

-Chris

Thanks Chris, et al.

However, I do want to clarify that, if I was to try this, it will kill only the apps that are running per the “command options escape” Force Quit Application list?