A gas control valve is the most expensive common part on a gas heater, and in a closet it is also one of the harder ones to reach. That combination makes the diagnosis worth doing properly.
What the part actually does
Gas arrives at building pressure and leaves at burner pressure, and the valve is the thing in between. It also holds the pilot port open while a flame is proved, and on an older standing-pilot unit it carries the temperature dial as well, which is why one part can produce such different complaints.
A pilot that will not hold, a burner that will not open, a temperature that wanders and a body that smells of gas are four different faults inside the same component. Two of them are usually caused by something else, and the closet's air is often that something.
Working through it
The flame is watched before it is measured: a soft flame that never wraps the probe produces a weak signal regardless of the probe's condition. Signal output is read next, then pressure at the inlet with the unit calling. Only after those are sound is the control's own hold tested.
A tower closet adds a step that a garage does not need. Blocked louvres, a door sealed for sound or a shared flue altered by another unit's work all starve the burner of air, and the resulting weak pilot looks exactly like a valve on its way out.
Access and the building
The gas may be isolated at a unit valve or at a building riser. Where the building controls it, the engineer is part of the visit, and the service window applies. The closet's clearance decides how easily the valve can be turned and tested.
Fitting it in a closet
Space decides the method. The control is reached through the front of the unit with the cover off, and on some closet installs the heater has to be turned slightly to give the body clearance. The part comes from the maker's list for the model and fuel, and the seals go in new.
The joint is leak-tested, the ignition sequence is followed to flame proved, and the closet door is closed before the final reading is taken. A unit that behaves perfectly with the door open can behave quite differently once its air supply changes.
Safety
A gas smell is an emergency for the floor. Leave, call 911 or the utility from outside, and notify the building. Soot or a yellow flame means the heater stays off until it is checked.