A well is plugged by placing cement in the wellbore or casing at certain intervals, as specified in California laws or regulations. The purpose of the cement is to seal the well-bore or casing and prevent fluid from migrating between underground rock layers. Cement plugs are required to be placed across the oil or gas reservoir (zone plug), across the base-of-fresh-water (BFW plug), and at the surface (surface plug). Other cement plugs may be required at the bottom of a string of open casing (shoe plug), on top of tools that may become stuck down hole (junk plug), on top of cut casing (stub plug), or anywhere else where a cement plug may be needed. Also, the hole is filled with drilling mud to help prevent the migration of fluids.
Useful reference: What are Orphan Wells? ¿Que Son Pozos Huérfanos?