A gas pipe must be opened to replace a gas valve for a water heater. What should be done with the remaining gas in the line?

A gas pipe must be opened to replace a gas valve for a water heater. What should be done with the remaining gas in the line?