Putin is no doubt walking a fine line. How much more degradation can he subject Russia to before it becomes untenable to the people who can make things difficult for his cabal? We are probably well past the point where he could declare victory and go home. He has nothing else focus public opinion on, since most of that has been expended in this failed invasion. It's the sunk cost fallacy—demonstrated in blood and treasure.
The thing is, Zelenskyy would/will/might (choose your own assessment) personally walk into the fire if that was the price of Ukraine's long term survival. Putin, however, will not do the same for either Russia or the Russian people.
This has a number of consequences, some of them ... uncomfortable. Let us make two assumptions:
1) Putin's reign would go (possibly quite literally. Goose, gander and stuff) out of the window if he made peace with Ukraine with nothing to show for it
2) Putin values his own future over Russia's future
Under those assumptions "keep going in the hope an opportunity presents itself" is not irrational. It is not a sunk cost fallacy, or any fallacy. It is not a good solution, and I don't actually think Putin does think it is one; it however is, from my understanding (as a random guy on the internet) of his perspective, the least worst feasible option to him at this time.
This is an entire rational choice under that specific reference frame -- however much we might disagree with the frame itself.