Radiative cooling is central to a wide range of astrophysical problems. Despite its importance, cooling rates are generally computed using very restrictive assumptions, such as collisional ionization equilibrium and solar relative abundances. We simultaneously relax both assumptions and investigate the effects of photoionization of heavy elements by the metagalactic ultraviolet (UV)/X-ray background and of variations in relative abundances on the cooling rates of optically thin gas in ionization equilibrium. We find that photoionization by the metagalactic background radiation reduces the net cooling rates by up to an order of magnitude for gas densities and temperatures typical of the shock-heated intergalactic medium and proto-galaxies (104 K ≲T≲ 106 K, ρ/〈ρ〉≲ 100). In addition, photoionization changes the relative contributions of different elements to the cooling rates. We conclude that photoionization by both the ionizing background and heavy elements needs to be taken into account in order for the cooling rates to be correct to an order of magnitude. Moreover, if the rates need to be known to better than a factor of a few, then departures of the relative abundances from solar need to be taken into account. We propose a method to compute cooling rates on an element-by-element basis by interpolating pre-computed tables that take photoionization into account. We provide such tables for a popular model of the evolving UV/X-ray background radiation, computed using the photoionization package cloudy.