He divorced her after the menstrual bleeding ceased and before she did ghusl
Divorce at the time of menstruation is an innovated and haraam divorce, and the scholars disagreed as to whether it counts as such. The majority of them are of the view that it does count, but others said that it does not and this is the correct view, as previously explained in the answer to question number 72417.
If the bleeding has stopped but she has not yet done ghusl, then the divorce is permissible and it counts as such, because in this case she is not regarded as menstruating. Ibn Qudaamah said in al-Mughni (10/336): Once the menstrual bleeding stops, the prohibition on divorce due to menses ceases to apply, and if her husband divorces her, then it is a permissible divorce which counts as such even if she has not done ghusl. This is the view of the two imams, Ahmad and al-Shaafa’i, because she has become pure by virtue of the cessation of bleeding. It says in Zaad al-Mustaqni’: If the bleeding stops and she has not done ghusl, nothing is permissible except fasting and divorce.
Shaykh Ibn ‘Uthaymeen (May Allaah have mercy on him) said in al-Sharh: The evidence that divorce is permissible after the bleeding stops is the words of the Prophet (blessings and peace of Allaah be upon him), “Tell him to take her back then divorce when she is pure or pregnant.” The woman becomes pure when the bleeding stops. End quote from al-Sharh al-Mumti’ (1/384).
Shaykh Muhammad al-Mukhtaar al-Shanqeeti (may Allaah preserve him) said: It is not permissible to divorce a woman when she is menstruating. If her bleeding stops and she has not yet done ghusl, and divorce takes place after the bleeding stops and before she does ghusl, what is the ruling? He said: The divorce counts as such, because divorce does not depend upon ghusl; as for the other things that are forbidden (during menses), ghusl is essential before they can be done, such as intercourse and entering the mosque, passing through it or staying in it, and other things that are forbidden during menses. End quote from Sharh Zaad al-Mustaqni’.
And Allaah knows best.