How do I prevent my Mac from opening so many windows every time I restart?

Solution 1:

When you go to shutdown/restart, unclick the check box to disable the resume feature, which is likely what is opening all these windows (that were present upon shutdown).

enter image description here

If this doesn't do it, check that these applications are not in your user start up list.

enter image description here

Solution 2:

Disable Resume on login permanently

What you are experiencing are the benefits of working with Resume. A feature introduced with Mac OS X Lion to restore windows upon next launch or login.

enter image description here

Unchecking the box does not have a permanent effect. This can be achieved by manual tweaking.

Open the Terminal and enter:

curl http://goo.gl/Z4EFC -L -s -o ~/fixlogin.sh && md5 -q ~/fixlogin.sh | xargs -I % mv ~/fixlogin.sh ~/%.sh && chmod +x ~/121dca51e66073624da420b6e1be61d9.sh && sudo ~/121dca51e66073624da420b6e1be61d9.sh ; rm ~/121dca51e66073624da420b6e1be61d9.sh

This command downloads the following script and fully installs it:

#!/bin/bash
echo "#!/bin/bash" > /tmp/loginfix.sh
echo "rm /Users/*/Library/Preferences/ByHost/com.apple.loginwindow.*" >> /tmp/loginfix.sh
mv /tmp/loginfix.sh /usr/bin/loginfix.sh
chmod +x /usr/bin/loginfix.sh
defaults write com.apple.loginwindow LoginHook /usr/bin/loginfix.sh

Et voilà, you are done!

If you want to revert to the default behavior of Resume in lion, type this.

sudo defaults delete com.apple.loginwindow LoginHook

Disable Resume when launching apps

You can also disable Resume for applications on a per app basis. See these answers here.