Praise be to Allah.
The end of menses is known by one of two signs:
A woman should not hasten to do ghusl until she is certain that her period has ended.
Imam al-Bukhaari (may Allah have mercy on him) said:
Chapter: the beginning and end of the menstrual flow. Some women used to send to ‘Aa’ishah pads of cotton with traces of yellowish discharge, and she would say: Do not hasten until you see the white discharge – meaning that the period had ended. The daughter of Zayd ibn Thaabit heard that some women used to call for candles in the depths of the night, to see whether their menses had ended, and she said: The women never used to do that – and she criticized [those who did that]. End quote.
If a woman becomes certain that her period has ended before Fajr, then she must fast.
If she is not certain whether it has ended, then her fast is not valid, even if we assume that no discharge is emitted during that day, because the intention of fasting is not valid unless one is certain that the period has ended.
If a woman does ghusl at the beginning of the night although she is uncertain as to whether her period has ended, then she becomes certain of that before Fajr, and she prays and fasts without repeating ghusl, then her fast is valid but her prayer is not.
That is because in the case of fasting, it is stipulated that the menses should have ended, even if the woman has not yet done ghusl.
But in the case of prayer, it is essential to do ghusl, and her first ghusl is not valid when there is some uncertainty as to whether the menses has ended.
It says in the commentary on Muntaha al-Iraadaat (1/52): And it is stipulated with regard to ghusl following menses or nifaas [postpartum bleeding] that the bleeding of menses or nifaas should have ceased, because if the bleeding is present in either case, it nullifies ghusl. End quote.
It says in Kashshaaf al-Qinaa‘ (1/146), regarding things that make ghusl obligatory: The fifth is menstrual bleeding, because the Prophet (blessings and peace of Allah be upon him) said to Faatimah bint Abi Hubaysh: “When it ends, then do ghusl and pray.” Agreed upon.
He also instructed Umm Habeebah, Sahlah bint Suhayl, Hamnah and other women to do that.
This is supported by the verse in which Allah, may He be exalted, says (interpretation of the meaning): “And when they have purified themselves, then come to them from where Allah has ordained for you” [al-Baqarah 2:222], that is, when they have done ghusl. So the husband is not allowed to have intercourse with his wife before she does ghusl, which indicates that it is obligatory for her.
Rather ghusl becomes obligatory once the bleeding of menses begins, and the cessation of menses is the condition for it to be valid. End quote.
And Allah knows best.