Ever since I first started using Mac OSX, I have been haunted by this strange behavior. On Windows, if I leave the machine to take a much needed break, or to take a phone call, go for a run, take a shower, etc. I can return to the machine later, with my work-in-progress intact, safe and sound. Or downloads in Firefox completed. Or whatever tasks that were left running, either still running or completed.
On the Mac, I have lost much work and time due to the Mac OSX intrusively restarting on its own. Drafts not saved? Say farewell – lost forever. Downloads disrupted – start over (unless resume miraculously works). This is especially exasperating, considering that Apple requires you to update the iPhone SDK/Xcode by re-downloading the whole package. Not patching, but re-downloading a 2GB+ file.
So, why exactly is the Mac restarting on its own, even when it is not idle such as having a download-in-progress?
Turns out that this is due to a rather useless Security feature. Ridiculously, the “Log out after 30 minutes of inactivity” setting is the culprit. So, to save yourself some agony, make sure you turn it off:

If your Mac has been suffering from this problem, hope the above helps!
Seriously, I have no idea what purpose this Security feature serves, other than to make you lose progress in your work. By comparison, on Windows, if the OS logs you out due to inactivity, it actually restores your session with your work-in-progress intact the next time you log in. You can even safely switch between user accounts on Windows, and log back into an account with its last session intact.
P/S: As far as security goes, you should just check the “Require password” option.