thank you for your query.
has absolutely no effect on pregnancy
If at all you are at high risk for abortion, masturbation can stimulate uterine contractions easily.
But as you mentioned, the baby was already dead inside, which is known as a missed abortion
causes for missed abortion can be genetic causes, infections, auto immune reasons, hormonal
imbalances, uterine abnormalities in shape and size etc.
You need to have complete evaluation for this.
Do not worry unnecessarily as masturbation is absolutely not related to all this.
Please vote helpful on this answer if you found it so.