This is what Scripture said: "Wise of heart and mighty in strength, who has hardened himself against Him and remained whole?" (Job 9:4). The generation of the Flood hardened themselves against Him; He swept them away in the waters. The generation of the Dispersion hardened themselves against Him; He scattered them throughout the whole world. The men of Sodom hardened themselves against Him; what was their end? "And the LORD rained down upon Sodom" (Genesis 19:24). Pharaoh said, "I do not know the LORD" (Exodus 5:2), and the Holy One, blessed be He, said, "Send out My people" (Exodus 5:1). And Pharaoh hardened himself against Him, as it says, "And it came to pass when Pharaoh stubbornly refused." Once the plague of the firstborn came, immediately he sent them out. Therefore it is said, "And it came to pass when Pharaoh sent out" (Exodus 13:17).
No One Hardens His Heart Against God and Stays Whole
Yalkut Shimoni on Torah 225:7
(שמות יג יז) זֶה שֶׁאָמַר הַכָּתוּב (איוב ט, ד) "חֲכַם לֵבָב וְאַמִּיץ כֹּחַ מִי הִקְשָׁה אֵלָיו וַיִּשְלָם", דּוֹר הַמַּבּוּל נִתְקַשּׁוּ כְּנֶגְדּוֹ שְׁטָפָם בְּמַיִם, דּוֹר הַפְּלָּגָה נִתְקַשּׁוּ כְּנֶגְדּוֹ הֱפִיצָם בְּכָל הָעוֹלָם, אַנְשֵׁי סְדוֹם נִתְקַשּׁוּ כְּנֶגְדּוֹ, מֶה הָיָה סוֹפָן, (בראשית יט, כד) "וַה' הִמְטִיר עַל סְדֹם". פַּרְעֹה אָמַר "לֹא יָדַעְתִּי אֶת ה'", והַקָּדוֹשׁ בָּרוּךְ הוּא אָמַר (שם א) "שַׁלַּח אֶת עַמִּי", וְנִתְקַשָּׁה כְּנֶגְדּוֹ "וַיְהִי כִּי הִקְשָׁה פַרְעֹה", כֵּיוָן שֶׁבָּאתָ מַכַּת בְּכוֹרוֹת מִיַּד שְׁלָחָן, לְכָךְ נֶאֱמַר וַיְהִי בְּשַׁלַּח.