Fiqh-us-Sunnah Volume 1, Purification and Prayer, Fiqh 1.070A.
Such bleeding occurs after the birth of a child, regardless if the child survived the birth or not. This type of bleeding has no minimum duration, for it could stop right after the birth, or there could even be no blood. Therefore, her confinement would end and she would be obliged to fast, pray, and so on. The maximum duration is forty days. Said Umm Salamah, “During the lifetime of the Prophet, the post-childbirth woman would be in confinement for forty days.” (Related by “the five,” except for an-Nasa’i.)
After recording the hadith, at-Tirmizhi states, “The knowledgeable companions, the following generation and those that came later agree that a woman experiencing post-childbirth bleeding had to stop praying for forty days unless her blood stopped. If her bleeding stops before that time, she is to make ghusl and start praying. If she sees blood after forty days, most scholars say that she is not to stop praying.”