Lion opens lots of windows automatically after a restart. How can I stop that? Lion opens lots of windows automatically after a restart. How can I stop that?

It's very annoying.

Is there a way to stop this?

I found an option in System Preferences ("Restore windows when quitting and re-opening apps") and disabled it but it doesn't seem to affect anything.
What you are experiencing are the benefits of working with resume. A feature introduced with Mac OS X Lion.

It restores the state of the computer when shut down. Very useful, when having to restart because of some installation procedure.
It reopens the used windows of applications. Quite useful since you do not have to navigate to a files location. Instead, just open the needed application to open the file.

Unchecking the box does not have a permanent effect. This can be achieved by manual tweaking.
Disable Resume upon login permanently
Open the Terminal and enter:
curl http://goo.gl/Z4EFC -L -s -o ~/fixlogin.sh &amp;&amp; md5 -q ~/fixlogin.sh | xargs -I % mv ~/fixlogin.sh ~/%.sh &amp;&amp; chmod +x ~/121dca51e66073624da420b6e1be61d9.sh &amp;&amp; sudo ~/121dca51e66073624da420b6e1be61d9.sh ; rm ~/121dca51e66073624da420b6e1be61d9.sh

This command downloads a script and fully installs it. 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

Kudos to Hexbrain who wrote the script.

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