Why does fuel click off when you fill your car?

There is a safety valve in the car, so when the gas tank is full you here the click of the valve shutting off