Automatic Gas Shutoff Valve (AGV) Information
An Automatic Gas Shutoff Valve (AGV) is designed, as its name implies, to automatically shut off the natural gas supply into a home or building in the event of a Magnitude ~5.4 or larger (major) earthquake. This can be a great advantage if no one is at home or if no one can get to the manual gas valve quickly enough after a major earthquake to turn it off to prevent gas from leaking from a cracked or broken line inside the home and starting a fire. AGVs shut off instantly during a major quake.
Note that if a major earthquake occurs while no one is at home, and if there is no AGV installed and a gas leak occurs, a resulting house fire may threaten the entire community. So an AGV can not only help protect an individual home from a natural gas fire, but potentially a much larger area.
The operation of an AGV (in this example the commonly-installed Little Fire Fighter model) is as follows:

AGVs are required by code in several cities and counties in quake-prone areas, and are recommended by Fire Departments and fire agencies. A manual gas valve is required by code for all residential and commercial natural gas services. You should know how to turn off the gas supply manually and should keep a gas valve shutoff tool or wrench near the valve. Directions for turning off the manual gas valve are as follows:

Note that if the gas supply is turned off either manually and/or by an AGV after a major quake, you may have a long wait until PG&E or a licensed plumber can come and inspect/repair your gas lines, turn the gas back on and relight any pilot lights. Keep in mind though, after a major quake (a Magnitude 6 – 7 quake is a real possibility on the Hayward Fault according to the USGS) experts have noted that natural gas service will most likely be turned off until PG&E can verify there are no broken transmission or distribution lines. Gas transmission lines do cross over the Hayward Fault line and it will take time to verify gas pipeline integrity and especially to repair any broken lines. So, after a local major quake, one shouldn’t rely on natural gas (or electrical power for that matter) being available for some time period, regardless if the gas into your individual home was turned off or not
Finally, note that PG&E and emergency preparedness training such as Oakland’s CORE/CERT program state that only PG&E or a licensed plumber is qualified to turn the gas supply back on safely. This is especially true during a major, damaging earthquake when strong shaking forces damage walls or foundations, or when a large gas appliance such as a stove or hot water tank shifts or falls over, resulting in a cracked or ruptured gas line. Certainly if you ever smell gas inside your house that you cannot locate the source of and turn off, or hear the hissing of a cracked or ruptured gas line, then immediately exit the house and turn off the gas supply with the manual valve (see above), whether an AGV shut off or not. Contact PG&E or a licensed plumber to inspect and repair the gas lines and turn the gas back on. Do not go back inside until deemed safe to do so.