This is mucus plug. Losing your mucus plug is one sign that your cervix is softening to prepare you for the big day.
There is no need for concern if your mucus plug dislodges even weeks before your due date - it could be hours, days or weeks before labor actually starts. Just keep an eye for signs of labor.