How to Stop Your Mac from Automatically Closing Inactive Windows

The Disappearing Documents

macOS includes a highly aggressive memory management system designed to keep your computer running smoothly, even if you have dozens of applications open. To save RAM, macOS will sometimes automatically terminate applications or close specific document windows if they have been hidden or inactive for a long time. You might minimize a PDF or a text document on Monday, and when you go to retrieve it from the Dock on Wednesday, you find the window is completely gone, and the application has to launch from scratch. This auto-termination is extremely frustrating if you use lots of reference windows that you only check occasionally.

How to Disable Auto-Termination in macOS

Apple does not provide a standard toggle switch in System Settings to disable this behavior. The auto-termination feature is baked deep into the operating system’s core. To stop your Mac from closing idle windows, you must change a hidden system preference using the Terminal application.

1. Open Spotlight Search by pressing Command + Spacebar.

2. Type Terminal and press Enter to launch the command line interface.

3. You need to write a new default rule to the global macOS preferences database. Carefully type or paste the following command exactly as written:

defaults write -g NSDisableAutomaticTermination -bool yes

4. Press Enter to execute the command.

5. The Terminal will not give you a confirmation message; it will simply return to a new prompt if successful.

6. For this change to take effect across the entire system, you must reboot your computer. Click the Apple logo () and select Restart…

Once your Mac boots back up, it will no longer silently kill inactive applications in the background. If you leave a Preview document open and untouched for a week, it will remain exactly where you left it, consuming RAM until you explicitly click the red ‘X’ or press Command+Q to close it.

How to Revert the Change

If you find that your Mac is running out of memory because it is no longer managing background apps automatically, you can easily turn the feature back on.

1. Open the Terminal again.

2. Run the following command:

defaults delete -g NSDisableAutomaticTermination

3. Restart your Mac to restore the default Apple memory management behavior.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.