To gross out some young people who find the body gross still: humans develop a mucous plug in the cervical canal during pregnancy. Losing the mucous plug (it will fall/leak out) usually means labor. You can dislodge it during rough sex so yeah lol. If you dislodge it before 37 weeks contact your obgyn just in case.
Edit: Oh and if you dislodge it after 37 weeks you might go into labor so hopefully at this point you know what to do in that event lol
Just to note: it can reform. So don't panic if you start losing it too early. Preterm labor isn't guaranteed. Especially if the reason for losing it is sex. It can also just start falling out a month before you go into labor, so don't get too excited at 38 weeks if it starts happening. You might still have weeks to go.