Terminates macOS app when all of its windows are closed.
Currently, the script only works with Preview, Notes, Calendar, and TextEdit.
The file selection dialog does not count as the app’s window, thus the app will be terminated if the file selection dialog is its only active window.