Self-control—or our ability to subdue our impulses, emotions, and behaviors in order to achieve longer-term goals—is what separates us from our ancient ancestors and the rest of the animal kingdom. Self-control is primarily rooted in our pre-frontal cortex, which is significantly larger in humans than it is in other mammals with similar brains. Thanks to our pre-frontal cortex, rather than immediately responding to every impulse as it arises, we can plan, evaluate alternative actions, and, ideally, avoid doing things we'll later regret.
The ability to exert self-control is typically called willpower. Willpower is what allows us to direct our attention, and it underlies all kinds of achievement, from school to the workplace. There is significant debate in science as to whether or not willpower is a finite resource. Some well-known studies have made a case that exercising willpower makes demands on mental energy. This concept, called ego depletion, is one possible explanation for why we're more apt to reach for a chocolate chip cookie when we're feeling overworked.
Recently, however, scientists have failed to replicate some of the studies underlying the concept of ego depletion. More research is underway, but the final verdict on whether we can “run out” of willpower remains to be seen.