Trends of electron affinity
Not exceptions, but see, theories say that going $L→R$ electron affinity increases up to halogens.
For the noble gases, $\Delta_\mathrm{eg}H$ is positive (energy required). While electron affinity is $0$. Which implies no tendency to lose electrons.
For $\ce{Be}$, the small size and nuclear charge are responsible, which is related to $\ce{Mg}$ due to a diagonal relationship.