When Athaliah, Ahaziah's mother, saw that her son was dead, she proceeded to annihilate all the royal heirs.
References for 2 Kings 11:1
Jehosheba, [who was] King Jehoram's daughter and Ahaziah's sister, secretly rescued Joash son of Ahaziah from the king's sons who were being killed and [put] him and his nurse in a bedroom. So he was hidden from Athaliah and was not killed.
Joash was in hiding with Jehosheba in the Lord's temple six years while Athaliah ruled over the land.
References for 2 Kings 11:3