That’s pretty much what happened in the books. More accurately he lost all hope for the world after being fed visions by Sauron to manipulate him. Hey wait…
I'm not sure even this is what destroys Denethor's mind though so much as it is the thought of the ring. He sees it as his by right of need. He sacrifices both his sons in his madness to have it, for the madness of power. His view of the world is so bleak that saving it in a way that destroys it seems "right" to him
It's not a particularly flattering portrayal- the military success is shown as belonging to Boromir more than Denethor- but at least it shows him sane.