Answer:
The causes could be many, although it is not very common during that late part of the gestation period. Some obstetricians will advise certain patients to avoid sex during the last few weeks of the pregnancy because some think that the hormones released in sexual activity can stimulate early labor. On the contrary, other doctors may advise couples to have sex in order to stimulate these hormones to induce labor when a delivery is overdue.
Note:
In the US, usually the term miscarriage is used during the earlier stages of pregnancy, and if the fetus is lost after that, it is called either a late miscarriage or a preterm birth.