I would speculate that it works similarly to most other mammals. Spikes of prostaglandin in the blood cause abortion via smooth muscle action and fluid production (or, if the embryo has developed to term, parturition rather than abortion). Prostaglandin is produced in the body cyclically. The corpus luteum releases progesterone that counteracts prostaglandin, but toward the end of the estrous cycle the CL degrades into an inert corpus albicans. Healthy implanted embryos release gonadotropin, which "stops the clock" for the CL so that it continues to produce progesterone. Eventually the placenta starts producing its own progesterone, and at that point the CL is no longer important. A dead or half-alive embryo is likely to produce neither gonadotropin nor progesterone, so it will be aborted and flushed on the next prostaglandin spike. The later this occurs in the pregnancy, the more stress is placed on the mother.
It's my impression that after implantation, this process is the same in humans as in other placental mammals. Thus menstruation might be more properly understood to be about flushing unimplanted zygotes rather than aborting unhealthy embryos.