When things aren't working the way you want them to, you need to be able to take a step back and review.
Not just the thing you're working on, but you also need to review yourself.
Is this still what you want to be doing? Is this thing you're working on heading in the same direction?
Obviously you don't want to be second guessing yourself every other week, but ploughing ahead indefinitely isn't the way to go either.
Re-commit if necessary, and go.