Is there a way to quit an app when the last item is closed?

Solution 1:

It's an implementation detail that the developer has to implement. In your example case, for Office, it's Microsoft.

Here is the Cocoa Objective-C code that allows the developer to implement this feature:

- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender
{
   return YES;
}

What you're observing is normal behavior on almost all applications on OS X and even the classic Mac OS. It's one of those things you should get used to on the Mac. However, these days, you are in luck that things are changing in your favor in Lion and probably later as OS X gains more features from iOS. As referenced in Lion Is a Quitter.

Lion will quit your running applications behind your back if it decides it needs the resources, and if you don’t appear to be using them. The heuristic for determining whether an application is “in use” is very conservative: it must not be the active application, it must have no visible, non-minimized windows — and, of course, it must explicitly support Automatic Termination.

Clearly, it looks like that version of Microsoft Office does not support Automatic Termination yet, but it may be coming.

So for now, the most you can do is check the program's preferences for options relating to quitting the application when it has no more windows open. Also, I encourage you to give Microsoft and / or any developer of apps feedback that you would like to see "quitting on last window closed" as a preference option or suggest they add support for Automatic Termination to their products.

Until then, just remember to use +Q when you are done with those applications that do not automatically quit when you close all its windows.

Solution 2:

I don't think that's a way for that. You can use Command + Q to quit the program, or click on the name of the app on the Menubar and select Quit.

Solution 3:

When I started using a Mac, I found that too. Some applications quit after the last window is closed and some (most, in my experience) don't.

Doesn't really answer your question, but I just got used to using + Q which will quit the application. That way if you have any open, unsaved documents it will prompt you to save them, then quit.