This is what I'd call an instance of the 'sunk cost fallacy' (also sometimes called 'escalation of commitment').
Wikipedia sums it up like this:
The phenomenon where people justify increased investment in a decision, based on the cumulative prior investment, despite new evidence suggesting that the decision was probably wrong.
I can think of two related (or at least relevant) proverbs:
In for a penny, in for a pound
You might as well be hanged for a sheep as a lamb.
However, they can be applied in situations that are not necessarily lost causes, so they fail to satisfy your condition that the person "knows they need to stop doing something that's not working".
There are some expressions in common use that convey the notion of total and/or irrevocable commitment, and which also imply that the enterprise in question has at least the possibility of failing:
"We're going all-in"
"We've crossed the Rubicon"
"We've come too far to turn back now"
and its variants,
"There's no turning back now!"
"We can't afford to abandon it at this stage"
The extent to which any of these implies or involves a prior investment of resources will depend on the context in which it is being used.