To start, go to Control Panel/System and select the Advanced tab. Click the Setting button in the Startup and Recovery section. Uncheck "Automatic Restart" in the System failure section. This should get your system to shut down properly.
Now; the cause of the system failure:
The only thing that I know will produce this behaviour on a regular basis is Roxio EZ CD Creator that does not have the upgrade patch for WinXP. If you are using EZCDC, go to the Roxio site and download and then install the patch and see if that solves the problem.
If that doesn't, use msconfig (Start/Run and type msconfig) and disable start up apps until the problem disappears.
HTH
Ron