What change of state takes place when a gas loses energy?
When a gas is cooled, it loses it's energy (the energy associated with thermal motion of molecules).
Consequently, intermolecular chaos becomes more ordered and as a result of intermolecular forces, the gas undergoes a phase change when cooled to certain temperatures.
Such a phase change can be condensation (gas to liquid) or deposition (gas to solid) depending on physical conditions and the nature of the substance.
However, for quantum gases cooled to ultra low (nearly 0 K) temperatures, there can be more exotic phase transitions like a Bose-Einstein condensation.