Getting Mac OS X applications to close after last window closed

68,930

Solution 1

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.

Solution 2

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.

Solution 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

Solution 4

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.

Solution 5

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

Share:
68,930

Related videos on Youtube

wfaulk
Author by

wfaulk

Updated on September 17, 2022

Comments

  • wfaulk
    wfaulk almost 2 years

    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.

  • Wolf
    Wolf over 14 years
    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.
  • Dan Rosenstark
    Dan Rosenstark over 14 years
    +1 for Arjan's comment. It's an amazing way to close a huge number of apps at once. You do this whenever you need to free up some memory.
  • Arjan
    Arjan over 14 years
    Actually, using the Application Switcher is the only time that open applications bother me. Too bad hiding applications does not keep them away from the application switcher.
  • Wolf
    Wolf over 14 years
    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!!!
  • wfaulk
    wfaulk over 14 years
    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.
  • Wolf
    Wolf over 14 years
    @Steve: Absolutely correct. Thanks for pointing it out. Unfortunately I can't edit/correct my post.
  • wfaulk
    wfaulk over 14 years
    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.
  • Syed Ismail Ahamed
    Syed Ismail Ahamed over 14 years
    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.
  • Syed Ismail Ahamed
    Syed Ismail Ahamed over 14 years
    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.
  • Syed Ismail Ahamed
    Syed Ismail Ahamed over 14 years
    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.
  • Syed Ismail Ahamed
    Syed Ismail Ahamed over 14 years
    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.
  • JoshP
    JoshP over 11 years
    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 :)
  • wfaulk
    wfaulk over 11 years
    Preview certainly doesn't automatically disappear for me under those conditions on 10.7.4.
  • Shinoy jose
    Shinoy jose over 11 years
    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.
  • brevno
    brevno over 11 years
    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?
  • wfaulk
    wfaulk about 8 years
    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.
  • Sampo
    Sampo about 7 years
    RedQuits closes the application if you click the red exit button, but not when closing the last window using Cmd+W.
  • Romain Vincent
    Romain Vincent over 5 years
    also, I am starting to use a Mac, and I don't get why apps with no opened window appear in the list when switching tabs with command-tab... Just, why? What was the idea behind this really?
  • jena
    jena over 4 years
    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).
  • Wowfunhappy
    Wowfunhappy about 4 years
    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!
  • j5shi
    j5shi about 4 years
    And those applications w/o a window are still taking up my memory!!