When a star is more massive then 2 solar masses, when it starts to collapse the electrons degeneracy pressure will not be enough. The electrons will move more and more furiously until the power produced by their motion will overwhelm the electromagnetic force, which is the force the keeps the electrons around the atom. Now when the electrons are no longer attached to the nucleus of the atom and moves around freely they will collide with protons since positive attracts negative charges. Then the electrons negative charge and the protons positive charge takes each other out and creates a neutral charge, a neutron. Now the star starts too fill up with neutrons and since the neutrons are more numerous then the electrons where(the neutrons that were already there and the newly created out of the electrons and protons), the neutron degeneracy pressure will be enough to stop the collapse of stars heavier then 2 solar masses.