I 've finished Seth Godin's little book The Dip. It's profoundly-simple stuff. I encourage you to pick it up, or at least read Seth's blog. Here's another quote from the book. And when it says "quit" it can mean your job, but it could be projects or programs or whatever.
Here's an assignment for you: Write it down. Write down under what circumstances you're willing to quit. And when. And then stick with it.
Here's a quote from ultramarathoner Dick Collins:
Decide before the race the conditions that will cause you to stop and drop out. You don't want to be out there saying, "Well gee, my leg hurts, I'm a little dehydrated, I'm sleepy, I'm tired, and it's cold and windy." And talk yourself into quitting. If you are making a decision based on how you feel at that moment, you will probably make the wrong decision.
...you should outline your quitting strategy before the discomfort sets in.
Seth Godin in The Dip, pages 71-72 (emphasis is the author's).