Cosmological bounds on the masses of stable, right-handed neutrinos