The Prophet ﷺ would sometimes be overtaken by dawn while in a state of major ritual impurity from intimacy with his wife, and he would then bathe and continue his fast.
حدثنا قتيبة حدثنا الليث عن ابن شهاب عن أبي بكر بن عبد الرحمن بن الحارث بن هشام قال
أن النبي ﷺ كان يدركه الفجر وهو جنب من أهله ثم يغتسل فيصوم
Agreed upon. Bukhari, Fasting, chapter, "One who wakes up in a state of major ritual impurity while fasting," hadith 1926, from the narration of Ibn Shihab Zuhri. And Muslim, Fasting, chapter, "The validity of the fast of one upon whom Fajr comes while he is in a state of major ritual impurity," hadith 1109, from the narration of Abu Bakr bin Abdul-Rahman, through the same chain.