there is a shutdown command in XP that you could shell to.

type shutdown /? for parameters. its easier, I think.