An earthquake valve (or seismic valve) is an automatic method to shut off the gas supply to a structure during a major earthquake, typically of 5.2 magnitude or greater. So Cal Gas recommends cutting off the gas supply immediately if you smell gas anywhere around your home after an earthquake. If no one is available to do this, an earthquake valve will automatically cut off the gas.
The automatic earthquake shut off valve works by using a metal ball that moves around on the inside between a ball seat and a trigger. When an earthquake shakes the valve, the ball falls out of the seat and onto the trigger. The trigger pushes the ball down, unhooking a latch, and causing the valve to close.
Once the valve is triggered, gas will be shut off to the home, and would need to be reset. Here are instructions on how to reset the typical automatic earthquake shut off valve.