64

I know it's just a pet peeve, but I hate it that Mac OS X's Preview.app stays open when it has no windows open. Is there any way to make it close when its last window is closed?

Since I don't see any option inside Preview to make that happen, I imagine that the answer might be applicable to other programs that have similar … idiosyncrasies.

I realize that this is not outside the OS's interface guidelines. That is, I recognize that this isn't a bug that will be fixed. I'm wondering if there is some way to automatically close selected GUI applications that have no windows open.

0

7 Answers 7

28

Try RedQuits:

RedQuits is there to help if you have ever tried to close an application with its red button and wondered why it is still open. With RedQuits, all programs now quit when there's only one window left for that program. If you want to quit and close all open windows of a program, just uncheck "Quit only when 1 window is left for that app." in the preferences.

3
  • 6
    What's funny is RedQuits itself doesn't quit when you press the red button, says so in the instructions. It's simple, which is nice, but no white list. Jan 6, 2013 at 18:02
  • 5
    RedQuits closes the application if you click the red exit button, but not when closing the last window using Cmd+W.
    – Sampo
    Apr 23, 2017 at 19:11
  • Link is dead @ 2022
    – Tetsujin
    Jun 1, 2022 at 6:57
23

In short: No.

--Answer stops here. Everything following is just my attempt to explain why.

What you are experiencing is the Mac philosophy of how applications should behave. Those who are closed after the last window dissapears are not behaving to Mac Interface Guidelines (though there are a lot out there). // Edit: This is not entirely correct, see posts below.

It has been that way since the very first Mac System (in 1984). I guess it'll stay with us for another 25 years to come. Maybe app devs will allow us to set that in the preferences.

Until then it helps getting used to Command-Q (the Apple key and q) to quit each and every app - and Command-W for just the active window.

12
  • 2
    My personal opinion as a comment: Working with both platforms every day: I got used to it. Doesn't make that much difference at all and - as always - there are two sides to it. While the app is running, each subsequent start is super-extremely-quick. Those apps that I use just once in a while could just as well be closed right after I use them. I got used to Apple-Q/Apple-W on the Macs much faster than Alt-F4/Strg-F4 on the Windowsers.
    – Wolf
    Oct 11, 2009 at 16:26
  • 34
    One can also press Q while using Command-Tab to switch applications (thus while still holding down Command), to quit the application that is currently highlighted in that application switcher.
    – Arjan
    Oct 11, 2009 at 16:32
  • 3
    What really, really annoyed me was that minimized apps showed up in the app switcher, but wouldn't be restored if choosing them. That I found very inconsistent. Just recently - after literally years of usage - I came across pressing ALT while switching to the (minimized) app would restore it. Hooooray!!!
    – Wolf
    Oct 11, 2009 at 20:46
  • 24
    To be brutally honest, I'm not all that interested in whether or not the symptom is normal. I'm interested in how to get rid of the symptom.
    – wfaulk
    Oct 12, 2009 at 16:26
  • 2
    I hate this behaviour - I set safari to reopen last session, but it only works if I remember to quit it instead of closing it. If I close it, I will loose my session and next safari window is empty. Same for sublime text or any other app that I expect to keep it's session after years of getting used to it. Btw on my Linux the quitting shortcut is Ctrl+Q, so it's not that far off compared to Windows, but it's still less convenient to press when my muscle memory is learned to Ctrl+Q (I have to use different fingers now basically).
    – jena
    Oct 10, 2019 at 9:03
3

I wrote an AppleScript application to do this for you.

In brief, it checks what applications are open, gives you the option to whitelist apps to be excluded from auto-quit, then every 60 seconds, quits all applications (that it can, due to limitations).

To alter the whitelist while it's running, click the icon in the dock for the selection dialog to reappear.

To quit, right click the Dock icon and choose "Quit"

AppleScript source and Application: http://files.me.com/kioarthurdane/6kjl9k

5
  • Seems like a good idea, except it doesn't work. I had to change "name" to "displayed name" in refreshWindowedProcess() to keep it from asking "where is this application", but even then it doesn't seem to ever quit anything.
    – wfaulk
    Oct 27, 2009 at 3:37
  • What version of OS X are you using? I wrote my script under Snow Leopard, not sure if there have been major changes to AppleScript.
    – dotHTM
    Oct 27, 2009 at 17:00
  • Nevermind, OmniGraffle Pro just did it to me. Very funny those cases were the name in Finder is not the actual file name... I'll see if I can write a correction to this using the bundle identifiers instead.
    – dotHTM
    Oct 27, 2009 at 17:06
  • Updated using bundle identifiers instead of application name (which can be different than the application's filename). In the source, there's a note about two lines commented out that will report the list of windows in each bundle identifier. I notice that many applications report having at least one window open despite no visible window being open. NetNewsWire is one such app having a long list of windows even after the main window is "closed". The Hit List is another app that retains it's single window is always open.
    – dotHTM
    Oct 27, 2009 at 19:15
  • Count of Windows = 0 seems the most obvious way of detecting your state for quitting, but this does not seem to do the job for all apps. Come up with your own conditions to add to my code. Since not all applications have an AS dictionary, it will be hard to check those apps for any other conditions (let alone time consuming to make a separate rule for each one). I'm more inclined to agree with the other answers given of "It's part of the Mac Culture to have a headless application still running" Unless it's doing something, it's not gonna be taking up much CPU or physical RAM.
    – dotHTM
    Oct 27, 2009 at 19:16
3

The automatic termination feature introduced in 10.7 partially addresses that for some applications.

If you open Preview, open at least one window in it, close all windows, and switch to another application, Preview is hidden from the Dock and application switcher. If you look at Activity Monitor, the process is still running and uses memory, but there might be some changes in how the process is managed.

The Mac App Programming Guide says that processes are actually terminated, so there might be something I'm missing.

  • Automatic termination eliminates the need for users to quit an app. Instead, the system manages app termination transparently behind the scenes, terminating apps that are not in use to reclaim needed resources such as memory.

[...]

Automatic termination transfers the job of managing processes from the user to the system, which is better equipped to handle the job. Users do not need to manage processes manually anyway. All they really need is to run apps and have those apps available when they need them. Automatic termination makes that possible while ensuring that system performance is not adversely affected.

2
  • 1
    Preview certainly doesn't automatically disappear for me under those conditions on 10.7.4.
    – wfaulk
    Dec 18, 2012 at 17:18
  • I missed your comment earlier, but it does for me in 10.8.2. Did you open at least one window (like open and close the preferences window) before hiding Preview?
    – Lri
    Mar 10, 2013 at 1:34
2

Another free small and simple app, Quitter, displays an X icon in the traybar which acts just like the closing button under Windows.

2
  • 4
    Welcome, and thanks for posting an answer! You should disclose your affiliation with the linked product/blog. It's not usually a problem when everything is kept above board :)
    – JoshP
    Dec 17, 2012 at 16:07
  • The download link for Quitter is broken. If it's your app as the above comment suggests, would you be willing to reupload it? Even better, if you're willing—I'd love to get the source code to hack on it a bit! Apr 12, 2020 at 18:39
2

Update 2022

RedQuits (http://www.carsten-mielke.com/redquits.html) works fine on macOS Monterey (Version 12.5.1).

  • Install and enable all three checkboxes:

enter image description here

  • Enable RedQuits in privacy > accessibility settings:

enter image description here

1

Override the following method in NSApplicationDelegate (which normally returns NO):

-(BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSapplication*)sender
{
return YES;
}
1
  • 1
    This is a question about how users might make this happen to existing applications, not how a programmer might get his program to do it. Thanks for your effort, though.
    – wfaulk
    Jun 23, 2016 at 20:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .