This is all very real, human stuff. Stuff we have all felt before.
But in a flash, David realize that his freedom was in God, not vindication on earth. Vindication on earth would only lead to more slavery to human emotions.
So, he chose the other path.
And God blessed him with freedom.