Optimization of a closed-loop gas system for the operation of Resistive Plate Chambers at the Large Hadron Collider experiments