In book 1 of Melachim (Kings) Chapter 2, Yoav took hold of the horns of the altar. What is the significance of this? Was it like a safety net or was he praying to g-d?
Yoav believed that grabbing on to the "horns" of the altar would provide him a sanctuary so that King Solomon would not kill him. The Judaica Press edition in the commentary on 1 Melachim 2:28 cites Makos 12a:
Our sages make note of Yoav's strange behavior. They conclude that Yoav made several miscalculations. He took hold of the horns when only the top of the altar offers asylum. Only the altar in the Temple offers asylum and he took hold of the altar in Shilo. He made one final mistake. The altar protects only the kohain in the midst of his service, whereas Yoav was not of the priestly family (Makos 12a).
Note that he may have thought that King Solomon would not dare have human blood spilled at the altar, but this is only speculation on my part.
Exodus 21:14 (Sefaria):
וְכִֽי־יָזִ֥ד אִ֛ישׁ עַל־רֵעֵ֖הוּ לְהָרְג֣וֹ בְעָרְמָ֑ה מֵעִ֣ם מִזְבְּחִ֔י תִּקָּחֶ֖נּוּ לָמֽוּת׃ (ס)
And if a man come presumptuously upon his neighbour, to slay him with guile; thou shalt take him from Mine altar, that he may die.
Ha'emek Davar commentary citing Ramba"m states that if there is no warning or sighting of the murder, a person may be considered an unintentional killer. Prior to the designation of refuge cities, the alter was considered the place of refuge. It's possible that Yo'av may have thought that he was in this category, and was seeking refuge this way. However, Shlomo killed him, not because of the murder, but because he rebelled against the king.