It is clear that Hezekiah feared for his life and the life of the kingdom of Judah. And like most others would have done, he asked God to rescue him. However, unlike many, his motivation wasn't self preservation.
Let's analyze his prayer.
First, he acknowledges the serious physical threat that Assyria poses: "It is true, O LORD, that the Assyrian kings have laid waste these nations and their lands. (2 Kings 19:17)"
Second, he distinguishes between Yahweh and the gods of those defeated nations: "They [the Assyrians] have thrown their [the defeated nations'] gods into the fire and destroyed them, for they were not gods but only wood and stone, fashioned by men's hands. (vs. 18)"
Finally, he begs God to deliver Israel not for his well being, but for God's glory: "Now, O LORD our God, deliver us from his hand, so that all kingdoms on earth may know that you alone, O LORD, are God. (vs. 19)"
In this case, God chose to answer Hezekiah's prayer favorably, and Jerusalem was spared.