Adonijah was David's 4th son and the logical choice to succeed to the throne. He was half-brother to Solomon. Adonijah and Joab (the general) planned to take the throne. However, David declared Solomon the king. Joab and Adonijah went to the altar for safety, but judgment had come. Joab feared for his life, he knew judgment was coming, but he waited until the end to seek forgiveness. King Solomon said to come forth, yet Joab refused and died there at the altar. Adonijah was dismissed but later made another attempt and was executed.
Adonijah and his general Joab figured they would be sheltered by grasping the horns of the altar of burnt offerings in the Tabernacle. They planned to put themselves under God's protection, but it did not work. Solomon conceded Adonijah a relief, however, Joab would not relinquish the horns of the altar, so he died there. The punishment fits the crime of murder like Joab.
Exodus 21:14, But if a man come presumptuously upon his neighbour, to slay him with guile; thou shalt take him from mine altar, that he may die.
Man's customs do not always follow God's will. God's purpose is fulfilled despite man's actions. Outward resort to ordinances does not win salvation. If man waits to hear his last rites, he will die there. Sacraments do not work - communion. Waiting until the deathbed to look at a minister instead of Christ does not work. Feelings of dread, despair, or despondency do not work. Yes, Christ will save a soul that is lost and that is truly repentant, but why wait?
Joab had consumed his time on earth attempting to protect his position as David's general. Twice David attempted to remove him, and on both occasions, Joab deceptively killed his opponents before they could assume their roles. Since Joab was in his administration, David was eventually liable for these deaths. In any case, for political and military reasons, David chose not to openly rebuff Joab. But rather, he had placed a curse on Joab and his family. In rebuffing Joab, Solomon was openly pronouncing David was not part of Joab's violations, in this way expelling the blame from David and setting it on Joab where it should have been. (2 Samuel 3:17-30, 2 Samuel 20:4-10)
2 Samuel 3:29, Let it rest on the head of Joab, and on all his father's house; and let there not fail from the house of Joab one that hath an issue, or that is a leper, or that leaneth on a staff, or that falleth on the sword, or that lacketh bread.
2 Samuel 3:39, And I am this day weak, though anointed king; and these men the sons of Zeruiah be too hard for me: the Lord shall reward the doer of evil according to his wickedness.
2 Samuel 19:13, And say ye to Amasa, Art thou not of my bone, and of my flesh? God do so to me, and more also, if thou be not captain of the host before me continually in the room of Joab.
Nothing can substitute for Christ's work and role His role in salvation.