I'm referring to this answer made by ProfRob about why neutrons are stable against beta decay in neutron stars.
I've partially understood the answer: when the Fermi's momentum of the electron $p_f = (3\pi^2n_e\hbar^3)^{1/3}$ increases above the maximum momentum $p_{max}$ produced by beta decay, the process stops. I calculated $q_{max}$ by imposing the conservation of energy and momentum in the center of mass frame : $m_nc^2 = \sqrt{p_e^2c^2 + m_e^2c^4} + \sqrt{p_p^2c^2 + m_p^2c^4}$ and $\vec{p_e} = -\vec{p_p}$ and found that $p_{max}$ is about $1.2 \rm\, MeV$. The notation is self-explanatory: $n_e$ represents the number density of electrons, $m$ is the mass and $\vec{q}$ is the momentum.
I don't get why, at equilibrium, the Fermi energies must be in this particular relation: $E_{F,n} = E_{F,p} + E_{F,e}$