Learning to know when to quit