2 Samuel - Chapter 17

David is betrayed by one of his close followers, Ahithophel, who betrayed the Lord's anointed to his enemy:

"Ahithophel said to Absalom, “I would choose twelve thousand men and set out tonight in pursuit of David. I would attack him while he is weary and weak. I would strike him with terror, and then all the people with him will flee. I would strike down only the king and bring all the people back to you. The death of the man you seek will mean the return of all; all the people will be unharmed.” This plan seemed good to Absalom and to all the elders of Israel."

But when this plan did not come to fruition, Ahithophel  killed himself:

"When Ahithophel saw that his advice had not been followed, he saddled his donkey and set out for his house in his hometown. He put his house in order and then hanged himself."

There is a clear parallel to the story of Judas, who also betrayed the Lord's anointed to his enemy.  And the plan was similar, with the High Priest saying that it was good for just one man to die, so the whole nation would not perish.

And that story also ended with Judas killing himself:

"When Judas, who had betrayed him, saw that Jesus was condemned, he was seized with remorse and returned the thirty pieces of silver to the chief priests and the elders. “I have sinned,” he said, “for I have betrayed innocent blood.” “What is that to us?” they replied. “That’s your responsibility.” So Judas threw the money into the temple and left. Then he went away and hanged himself."