Although extremely uncommon, it’s not unheard of for a Mac, particularly an older model, to restart unexpectedly. If it happens once, chalk it up to cosmic rays and move on. But if it happens multiple times, try these two things right off. First, use compressed air to remove dust from cooling vents or the inside of the Mac, if you can open it up. Dust can cause heat buildup, which can in turn cause restarts. Second, try plugging the Mac into a different electric circuit or, ideally, into an uninterruptible power supply (UPS). Dirty power can provoke all sorts of undesirable behavior—including unexpected restarts—and shorten the lifespan of the Mac’s electronic components. Remember, clean air and clean power make for a happy Mac.