All perfect praise be to Allaah, the Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad, sallallaahu ‘alayhi wa sallam, is His Slave and Messenger.
If the menstrual blood flowed even a moment before sunset, then your fasting would be invalid and you have to repeat it. If you simply felt that it was flowing and it did not come out except after sunset, then your fasting would be valid. In his book Ad-Dimaa’ At-Tabee‘iyyah Linnisaa’ (the natural blood of women), Shaykh Ibn ‘Uthaymeen said, “If the woman menstruates while fasting, then her fasting will be invalid even if her blood flow occurs a moment before sunset. If fasting that day is obligatory, then she will have to make up for this day. However, if she feels she is about to have her menses but no blood flow actually occurs till after sunset, then her fasting will be valid and will not be invalidated in accordance with the sound opinion on this matter. This is because there is no ruling regarding the blood inside the woman's body.”
In a Fatwa in one of his monthly sessions, he said, "If the menstrual blood flowed even a minute or less before sunset, then her fasting would be invalid."