Periodically, circular muscles at the hindgut's entrance pinch off and excrete a piece of the prostyle. The anus is in the part of the mantle cavity that is swept by the outgoing lane of the current created by the gills. Carnivorous mollusks usually have simpler digestive systems.
The particles are sorted by another group of cilia, which send the smaller particles, mainly minerals, to the prostyle so that eventually they are excreted, while the larger ones, mainly food, are sent to the stomach's cecum (a pouch with no other exit) to be digested. The sorting process is by no means perfect.

Picture