The cosmological dynamics of a quintessence model based on real gas with general equation of state is presented within the framework of a three-dimensional dynamical system describing the time evolution of the number density, the Hubble parameter, and the temperature. Two global first integrals are found and examples for gas with virial expansion and van der Waals gas are presented. The van der Waals system is completely integrable. In addition to the unbounded trajectories, stemming from the presence of the conserved quantities, stable periodic solutions (closed orbits) also exist under certain conditions and these represent models of a cyclic Universe. The cyclic solutions exhibit regions characterised by inflation and deflation, while the open trajectories are characterised by inflation in a fly-by near an unstable critical point.