Diffusion cooling of electrons in a finite gas