How do I turn off "Close windows when quitting an app" with `defaults write`?

It's easy to manually turn off the "Close windows when quitting an app" feature, but how do I do it in a script with defaults write?


If you haven't found yet, try this (works on Mojave at least) :

  • Enable : defaults write NSGlobalDomain NSQuitAlwaysKeepsWindows -bool false
  • Disable : defaults write NSGlobalDomain NSQuitAlwaysKeepsWindows -bool true

Have a nice day


The other answer gives the right raw materials but is exactly backwards.

You turn OFF "Close windows when quitting an app" like this:

defaults write NSGlobalDomain NSQuitAlwaysKeepsWindows -bool true

UPDATE: the other answer was originally correct, as the author composed it, but a moderator "corrected" it 4 minutes later to make it backwards. I've restored it as the accepted answer. Please up-vote the other one. (You can upvote mine too if you want, to thank me for noticing the moderator's error, but please at least give credit to the original author for finding the correct information.)