I'm trying to set up an Automator script to do a bunch of routine things before I pull my laptop off it's thunderbolt dock – turn WiFi back on, eject disks, and quit certain applications. It's this last one that's currently vexing me – using either AppleScript or the Automator "Quit Application" action, the script stops after executing the quit order. The app I'm currently trying to quit is MakeMKV. I've also tried it with Zoom (another app I'd like to close out).
It only stops if it actually has to quit the app – and the apps do quit. If the app isn't open, the step is skipped and moved past. The error I get is:
"Quit Application was stopped" if using the Quit action or
"Run AppleScript was stopped" if using the AppleScript action.
I've tried it with Chrome, Messages, and Notes, all of which quit gracefully. These other apps are executing the quit order – is there any way to figure out why the script is stopping, and suppress whatever is doing it?
edit: Code block looks like the following:
Best Answer
You can try these three potential solutions to see if either fare any better than the built-in Automator action.
The first is a plain AppleScript handler that takes a list of exceptions (apps that are exempt from being quit), and then proceeds to send a quit command to all the others (they being any application process not belonging to a file in the
/System
directory--therefore, Finder and System Events will be spared, but Automator will not unless it is specified in the list of exceptions,X
):The second uses the same method as above to retrieve a list of running applications but it grabs their
pid
numbers. These are passed en masse to ado shell script
call tokill
the applications (some people get nervous about this, possibly because the name of the command sounds like it's a bad action to perform, but it's perfectly safe, and very standard. Applications typically also save their window and document states, so thekill
command can allow them to retrieve the.savedState
data when re-opened later.The last solution is an AppleScript-ObjectiveC handler that, once again, obtains a list of the running applications that aren't located anywhere in the
/System
folder, and don't appear (by name) in the list that's passed to the handler:I haven't tested this handler to see what permissions need granting, as I didn't want all of my programs to terminate. But let me know if there are any hiccups and I'll direct you accordingly. The word
terminate
inside the handler can be replaced byforceTerminate
(case sensitive) to do a force quit on each application instead. This, if it were me, would actually be my preference, as I have set my system to save the state of applications on forced terminations, and it avoids the "Do you want to save the current document?" banality.