Quitting a losing effort permits you to place bets in a more likely to win effort. There is a huge opportunity cost to using bad judgement to continue a failing project.
It has to be intelligent persistence, though. Only persist if you firmly believe that the potential reward outweighs the cost of continued effort.
Quitting a hopeless avenue of exploration frees you up to pursue greater chances of success elsewhere. It all depends on context.