Disable Mac OS Lion’s “Restore windows” setting on an individual per-application basis

The “General” PreferencePane in Lion’s ‘System Preferences’ windows contains a “Restore windows when quitting and re-opening apps” item. However, sometimes this behaviour does’t make sense – after a reboot I found, for example, that the OS X Installer had re-launched and was asking for a package to install!

This can be prevented on a per-application basis with the Terminal command:

defaults write ‹application id› NSQuitAlwaysKeepsWindows -int 0

(… with a terminating zero, not letter “o”)

This will affect the current user, or the entire system if prefixed with “sudo“. The Application ID can be found in ‘~/Library/Preferences‘ – so, for example, preventing Installer.app from automatically restarting can be achieved by executing in Terminal:

defaults write com.apple.installer NSQuitAlwaysKeepsWindows -int 0

… but this could also be used for other intentionally ephemeral applications such as TextEdit.app or, depending on your normal usage, Terminal.app.