Optimization of a closed-loop gas system for operation of resistive plate chambers at the Large Hadron Collider