How to quit multiple application on mac using an automator app?

Solution 1:

An Automator app doesn't usually stay open after its run if all it's doing is opening a few apps. That said, since you want to open and close the same apps with a single app that stays open and then closes the target apps when you quit the app that opened them, I would choose to do this with a stay open AppleScript application.

The following example AppleScript code, shown below, will open the three apps in the theseApps list and then close them when you close the app made from this code.

In Script Editor, copy an paste the example AppleScript into a new untitled document.

property theseApps : {"Contacts", "Dictionary", "Notes"}

on run
    repeat with thisApp in theseApps
        activate application thisApp
    end repeat
end run
on quit
    repeat with thisApp in theseApps
        quit application thisApp
    end repeat
    continue quit
end quit
  • Obviously, change the names of the app in the example AppleScript code to meet your needs.

Now save the script as an AppleScript application while checking the Stay open after run handler check box.

The example AppleScript code, shown above and as is, when saved as a stay open AppleScript application, worked for me without issue on macOS High Sierra.


Note: The example AppleScript code is just that and does not contain any error handling as may be appropriate. The onus is upon the user to add any error handling as may be appropriate, needed or wanted. Have a look at the try statement and error statement in the AppleScript Language Guide. See also, Working with Errors.

Solution 2:

An easy way to do this is with Keyboard Maestro which can run commands to open apps together or quit a group of apps when a particular app quits.

All you'd need to do is specify the app that you want to monitor when it quits, and then tell it to quit the other apps as well.