We discuss how the thermalization of an elementary quantum system is modified when the system is placed in an environment out of thermal equilibrium. To this aim we provide a detailed investigation of the dynamics of an atomic system placed close to a body of arbitrary geometry and dielectric permittivity, whose temperature $T_M$ is different from that of the surrounding walls $T_W$. A suitable master equation for the general case of an $N$-level atom is first derived and then specialized to the cases of a two- and three-level atom. Transition rates and steady states are explicitly expressed as a function of the scattering matrices of the body and become both qualitatively and quantitatively different from the case of radiation at thermal equilibrium. Out of equilibrium, the system steady state depends on the system-body distance, on the geometry of the body and on the interplay of all such parameters with the body optical resonances. While a two-level atom tends toward a thermal state, this is not the case already in the presence of three atomic levels. This peculiar behavior can be exploited, for example, to invert the populations ordering and to provide an efficient cooling mechanism for the internal state of the quantum system. We finally provide numerical studies and asymptotic expressions when the body is a slab of finite thickness. Our predictions can be relevant for a wide class of experimental configurations out of thermal equilibrium involving different physical realizations of two or three-level systems.