Best TVs 'She-Hulk' Review Up to $1,000 Off Samsung Phones Best Streaming TV Shows Home Bistro Review 8 Great Exercises Amazon Back-to-School Sale Best Phones Under $500
Want CNET to notify you of price drops and the latest stories?
No, thank you

Managing automatic application termination in Lion

OS X Lion will quit programs that are not in use, but this behavior can be disabled if it affects your workflow.

A confusing aspect of OS X for those who regularly use other operating systems like Windows, is that quitting an application is separate from closing all of its windows. As a result, people used to Windows may simply close all windows and end up with numerous applications open at the same time, which can hog resources like RAM, use CPU time, and potentially result in slowdowns and reduced battery life.

In OS X Lion, Apple dealt with this problem in part by implementing a feature called automatic application termination, which will quit applications that are not in use. I covered application termination in a previous article, but in essence if you close all windows to an application and then do not interact with it for a while, you may see it eventually disappear from the OS X Dock (it does not fully quit, but does require you to relaunch the program in order to use it). Therefore if a user continues to close windows and not worry about actually quitting an application, the system should manage this for the user.

In many cases this might be a desired behavior; however, it can be cumbersome if you wish to keep applications open in the background to have them ready to use. Some people have workflows in which they use Command-Tab to switch to their applications instead of relying on the Dock, the Finder, or Spotlight to launch them when needed, and having programs seemingly randomly quit will impact these workflows.

While you can overcome this behavior by ensuring the programs you use either have at least one window open or are otherwise active (streaming, connecting, and monitoring), you can also turn this behavior off centrally.

Many of the services that run in the background and make up the OS X experience contain a number of hidden variables that the programmers use for troubleshooting and testing purposes. Even though these are not made available to the public through the system's preference panes, they nevertheless can be used to modify the system behavior or that of applications, sometimes in desired ways.

Automatic application termination disabling command in the Terminal
Running this command in the Terminal as is shown here, followed by restarting or logging out and logging back in, will prevent automatic application termination in OS X. (click for larger view) Screenshot by Topher Kessler/CNET

These variables can be enabled and configured by placing them within various preference files manually using the "defaults" command. And you can look up many that have been found and characterized so far by performing a Web search for the term "defaults write" along with other key words like "Mac" or "OS X," and then try them out on your system if you choose (be sure you understand what they do beforehand, and also how to revert the changes if necessary).

With regard to the automatic application termination feature in Lion, such a variable exists that will disable this feature, which was recently found by users in the Apple Discussion Communities. To set it, as with other variables open the Terminal and run the following command (copy and paste it):

defaults write -g NSDisableAutomaticTermination -bool yes

This command uses the "defaults" system (the preferences writing routines in OS X) to target the hidden "global" preferences file (indicated by the "-g" flag) to add the variable "NSDisableAutomaticTermination" and set it to be positive ("yes" or "true"). The affected preferences file is a hidden file within your user account, which contains a number of environmental variables such as pointer speeds and language preferences. The variables within this file load when you log in, so in order to invoke the changes made by the command above, simply log out and back into your account.

To undo the changes to this command, you can repeat it and change the last "yes" value to "no," but since this particular variable is a custom and normally hidden one that is not in the global preferences file, you can remove it completely by running the following command:

defaults delete -g NSDisableAutomaticTermination

Questions? Comments? Have a fix? Post them below or email us!
Be sure to check us out on Twitter and the CNET Mac forums.