Learning to Stop and Think