To fully grasp the comments below you should probably read 2 Kings 3. However, if you choose not to, here is a brief synopsis.

In 2 Kings 3, the “good guys” (Jehoram, king of Israel, Jehoshaphat, king of Judah, and the king of Edom) are about to totally wipe out the “bad guys” (Mesha, king of Moab, and the Moabites). But at the moment of imminent victory we read this surprise ending: When the king of Moab saw that the battle was going against him, he took with him 700 swordsmen to breakthrough, opposite the king of Edom, but they could not. Then he took his oldest son who was to reign in his place and offered him for an ascension offering on the wall. And there came great wrath against Israel. And they withdrew from him and returned to their own land (vv. 26-27).

PJL Kings

In his commentary, where this episode is explained in greater detail, Peter Leithart offers the following:

This unnerving story reveals something of God’s ways with humanity in general. What is God up to in history or in the specific history of our individual lives? That is often difficult to answer, and frequently, just when we think we have a sense of what God is doing, he turns things inside out and upside down and does something else. He is a living God, and that means he is the God of surprise endings. He does this not because he takes malicious delight in toying with us, nor does he trap us to guffaw over the resulting pratfalls. The God of surprises is wholly righteous, wholly good, wholly just, wholly love, wholly light without a shadow of turning. He is faithful with the faithful, but the faithful throughout the centuries testify that God is a God of surprises. God surprises us because we have only the slightest grasp of what is actually going on in history or in our lives. God surprises us because he is doing far, far more than we can imagine, and his plans are far bigger that we can perceive. God surprises us with roadblocks and obstacles because he wants us to grow up from complaining, sentimental childish Jehorams into mature adults, into the image of Jesus, who learns obedience by what he suffers” (182).