Usually your body will spontaneously abort a dead fetus, but a pregnancy farther along could require medical intervention - a d&c will usually suffice for earlier pregnancies, but if you're farther along (I want to say over 20 weeks, but I could be off on the exact timing), actual labor might be necessary to remove the baby. I know of a couple women that had to be induced after a heartbeat could no longer be found.
If this is happening to you or someone you know, I am so sorry - it's a terrible ordeal. If you are pregnant and suspect the baby is not alive, call your doctor ASAP. It needs to be taken care of right away or you could jeopardize your health. Best of luck.
Usually the baby will expell itself, it could cause infections if not.