Is it actually shutting off or just going into sleep mode? If there are lights on the tower on, then the machine is still on.
Right-click on the desktop (anywhere not occupied by an icon) and choose "Properties".
Click on the "Screen Saver" tab
Click on "Power"
System Standby, Turn off Hard Disk, and System Hibernates should be set to "Never", unless you want them to do their thing. If any of these are set to a time, that is most likely the problem.