#How did King Joash prevent King Hazael from attacking Jerusalem?

Joash took all the holy objects that Jehoshaphat and Jehoram and Ahaziah had consecrated to Yahweh, his own holy things, and all the gold that was found in the storerooms of the houses of Yahweh and of the king, and he sent them to Hazael, king of Aram. Then Hazael went away from Jerusalem. [12:18]