0

The AppleScript way to quit a Mac application is:

tell application "iTunes"
  quit
end tell

How do you quit an app with JavaScript for Automation (JXA)?

Alan W. Smith
  • 24,647
  • 4
  • 70
  • 96

1 Answers1

4

Quitting an application with JavaScript for Automation is done like this:

var itunes = Application('iTunes');
itunes.quit();

(Note that the Application call looks inside the /Applications directory. Any app there can be called by name.)

Alan W. Smith
  • 24,647
  • 4
  • 70
  • 96
  • Note that in general this works. However, I've found that if an application is open but has no windows (ie, because it has not been "hard quit" yet), calling quit() does not work. Is there another way? – SeanRtS Oct 27 '21 at 13:41