Clean shutdown/restart from terminal in 10.7+
While writing up this question I made a discovery that might help others to almost fully solve this issue:


  
  ~/Library/Preferences/com.apple.loginwindow.plist contains TALLogoutSavesSate set to NO
  


While this is true, there is another file located at ~/Library/Preferences/ByHost/com.apple.loginwindow.*.plist that contains an array called TALAppsToRelaunchAtLogin. That array contains a list of app windows currently open. 

Deleting this array, or in a more blunt way the whole file, and immediately restarting almost completely fixed the issue.

The remaining issue is when the machine starts up any open Finder windows are restored and if you had one or more terminal windows and actually ran the shutdown command from that window it causes it to be restored when Terminal is started again, but via SSH or a daemon seems to work fine.

I don't really think this a suitable solution in the long run but so far in my little testing it does seem to work.

upon further research it seems you can hook a script into login so it always deletes the file:
defaults write com.apple.loginwindow LoginHook /usr/bin/loginfix.sh

:edit, along the same lines as the terminal window it looks like each individual app is saving it's state, so for example if you open TextEdit, make some changes and then restart the machine using the above method when the you log back in and start TextEdit you end up with the document you had open. Looking in ~/Library/Containers/com.apple.TextEdit explains everything