|Tip 208||Stop Automatic File Opening|
When you start a program, OS X will attempt to open any files that were open the last time you quit the app. This is either very useful or extremely annoying, depending on your personal preference, but here’s how to take control of this feature.
Permanently Deactivating App Restore Systemwide
You can permanently deactivate this feature in System Preferences (Apple menu→System Preferences). Click the General icon and then check Close Windows When Quitting an Application.
Temporarily Deactivating for an Individual App
However, if you want to temporarily deactivate automatic file restore for a particular application when you’re quitting it (so that it’ll open “clean”), simply quit the app using the Option+Command+Q keystroke rather than the usual Command+Q key combination. Alternatively, hold down Option before clicking the Quit option on the program’s menu—you’ll see the menu option change to Quit and Close All Windows.
Permanent Disabling for an Individual App
It’s also possible to permanently deactivate the feature on an app-by-app basis. You could turn it off for TextEdit, for example, while leaving it active for all other apps. Here are the steps required:
Quit the app in question if it’s running, open a Terminal window (open Finder, select the Applications list, and then in the list of applications double-click Terminal within the Utilities folder), and type defaults write; then follow it with -app and then the name of the app, followed by NSQuitAlwaysKeepsWindows -bool FALSE. The line for TextEdit would read as follows, as an example:
defaults write -app TextEdit NSQuitAlwaysKeepsWindows -bool FALSE
The following deactivates the feature for Pages, which is part of Apple’s iWork Suite:
defaults write -app Pages NSQuitAlwaysKeepsWindows -bool FALSE
For non-Apple apps such as Microsoft or Adobe applications, it’s instead necessary to specify the preferences domain within the command line. Don’t worry—this simply means a command similar to the following for a Microsoft Office app, which will deactivate the feature for Microsoft Word, although you could swap out Word for Excel, PowerPoint, and so on, to deactivate the feature for those particular apps:
defaults write com.microsoft.Word NSQuitAlwaysKeepsWindows -bool FALSE
The following will disable the feature for Excel:
defaults write com.microsoft.Excel NSQuitAlwaysKeepsWindows -bool FALSE
For Adobe Create Suite apps, use the following line, which will deactivate the feature for Photoshop, although you can again swap out Photoshop for the name of any other Creative Suite app, such as Illustrator:
defaults write com.adobe.Photoshop NSQuitAlwaysKeepsWindows -bool FALSE
Restart the app. The changes will take effect immediately. Note that with some apps, the first time you run the app, it might restore its old windows. However, quitting and restarting once more will put a stop to it.
Should you want to reactivate window restore for the app, quit the app and open a Terminal window. Then type the following for Apple apps, again substituting the name of the app (the following will reinstate window restore for TextEdit):
defaults delete -app TextEdit NSQuitAlwaysKeepsWindows
For Microsoft Office apps, use the following, again substituting Word if necessary for the name of the app in question:
defaults delete com.microsoft.Word NSQuitAlwaysKeepsWindows
For Adobe Creative Suite apps, you can use the following, again substituting Photoshop if necessary for the name of the app in question:
defaults delete com.adobe.Photoshop NSQuitAlwaysKeepsWindows
Quit and restart the app for the changes to take effect. Again, you might have to quit and open the app once more for the changes to actually take effect. You might also try logging out and back in again.