-n is a VERY BAD IDEA!
-n If the -o is specified, prevent the file system cache from being
flushed by passing -n option to halt(8) or reboot(8). This
option should probably not be used.
Not flushing your file system cache can result in lost data. The only thing that saved you is you did not have the -o option also specified.
sudo shutdonw -r now
sudo shutdown -h now
are about the extent anyone should be doing, unless they are really Unix system admin aware.
And since the Unix command line side of the house does not know anything about the GUI, shutdown will not change the GUI's re-launch and option previous apps and windows.
See this hint on using an Applescript to set the boot volume and then
tell "System Events"
You'll need to read through the comments to find the option to boot Windows, and also a nice option to only switch the boot volume for this restart.
It uses the do shell script to run the shell commands, so you could just wrap it all in a shell instead.