There are times when quitting is necessary for perspective, and where you can get the same task done quicker by quitting and moving onto something else, and then when you need to, coming back, than you would by pushing for a deadline. Learning to recognize that there are signs of "I don't really understand this problem, so I should come back after I have a chance to digest my failure today" and recognizing when that's a good idea takes some time though.