Yes, the life of your wife and baby is more important than anything. You have now two option:
1) Before she finishes her 6-months stay outside Qatar, you have to go to the immigration authorities (either in Medina Khalifa or Airport Immigration) and apply for extension of her exit permit for a further period of 6-months. There is specific format in which you can apply with supporting documents like a medical certificate saying "she is having a complicated pregnency and not adviseable to travel till she derlivers" something like that. They will charge you QRs. 2000/- for that if your application is approved. Then she can stay one year outside Qatar.
2) If you do not get the extension of her Exit Permit, her RP will become invalid. In that case, in the month of November, you can apply for a "special permit" to allow her to come back to Qatar as she will still be having a residence visa. You have to apply for the "special Permit" with supporting documents like medical certificate stating the reason. It is the samy authoritiy.

Hope things will be fine with you.
Best of luck.