2 Samuel 17:23

And when Ahithophel saw that his counsel was not followed, he saddled his ass, and arose, and gat him home to his house, to his city, and put his household in order, and hanged himself, and died, and was buried in the sepulchre of his father.

The moment came when Absalom rejected Ahithophel's counsel and preferred Hushai's counsel instead, and that choice was a fatal mistake. Ahithophel saw that his counsel was not followed and clearly foresaw the result, knowing that the cause of the rebels was lost. He knew there was no hope for himself, because as counselor he had instigated Absalom's greatest crimes, having encouraged the rebellion, counseled abominable wickedness to dishonor his father David, and advised the slaying of David and planned its accomplishment, thereby cutting off the last possibility of his own reconciliation with the king. He was also stung that another was preferred before him even by Absalom, and he became jealous, angry, and desperate.

In that state he returned home to his house in his city, put his household in order, and hanged himself and died, thus perishing by his own hand. In this he perished as one of the instigators of rebellion in Israel. His end was the result of wisdom exercised with high endowments but without making God his counselor. His fate proves that though Satan allures men with flattering promises, the wages of sin is death.