If a woman wants to do ‘Umrah but is afraid her menses may come before she completes it, she may stipulate a condition [about exiting ihram], then if she gets her menses she can exit ihram and will not have to do anything.
The basic principle about it being permissible to stipulate such a condition is the report narrated by al-Bukhaari (5089) and Muslim (1207) from ‘Aa’ishah (may Allah be pleased with her) who said: The Messenger of Allah (blessings and peace of Allah be upon him) entered upon Dubaa‘ah bint az-Zubayr and said to her: “Perhaps you want to do Hajj?” She said: By Allah, I am always in pain. He said to her: “Go for Hajj but stipulate a condition and say: O Allaah, I will exit ihram from the point where You have prevented me (from continuing, if some problem should arise).”
If a person is afraid of illness or if a woman fears that her menses may come, she may stipulate this condition.
Shaykh Ibn ‘Uthaymeen (may Allah have mercy on him) was asked: With regard to stipulating a condition [about exiting ihram] in Hajj, are there any specific cases in which the pilgrim should stipulate this condition and say: “If something prevents me (from continuing), I will exit ihram from the point where You have prevented me (from continuing)”?
He replied: Stipulating a condition in Hajj means saying, when entering ihram: “If something prevents me (from continuing), I will exit ihram from the point where You have prevented me (from continuing).”
Stipulating this condition is not prescribed unless there is some fear of sickness, or if a woman fears that her menses may come, or if a person is delayed and fears that he may miss Hajj. In these cases he or she should stipulate this condition. If he stipulates this condition and something happens that prevents him from completing the rituals, then he may exit ihram and leave, and does not have to do anything.
But if he is not afraid (of any of these things happening), the Sunnah is not to stipulate a condition; rather he should be firm in his resolve, put his trust in Allah and think positively of Allah, may He be glorified and exalted.
End quote from Liqa’ al-Baab al-Maftooh, 25/18
And Allah knows best.