Are you sure the computer is restarting and not just going into standby/sleep mode? That sounds like what it's doing.

There's a setting that controls how long your computer can sit idle before it starts conserving energy and goes into a lower power-consuming state, such as standby, sleep or hibernate. When you activate the computer again (usually by jiggling the mouse or pressing a key on the key***rd), by default you're presented with the login screen and are required to sign in again.

It's advantageous to use these settings as apposed to exiting out of all your programs and completely turning off your computer each time you walk away for a few minutes, as well as it preventing other people from getting on your account once you've walked away.