The thing is, gravity's actually an incredibly weak force by comparison to every other fundamental force (this is why you can have dust clinging to the ceiling -- a small amount of electric force is more than enough to "overcome" gravity and prevent the dust from falling). There is so much energy being released inside the star due to nuclear fusion that there just isn't any way for the star to collapse.
Even then, not all stars do collapse. Stars the size of our Sun actually greatly expand during the period of their death (the Sun will inflate to the size of about Mars' orbit once it starts fusing Helium into Carbon (2He

Be, Be + He

C) because there will be a lot more energy and gravity won't be enough to contain it until that cycle's done), though after that expansion they do shrink back down eventually (after there's nothing left to undergo fusion, the energy output drops dramatically so gravity can overcome the star's size) and it will become a brown dwarf.
Stars that are much larger than our Sun get hot enough in their core to burn past Carbon. In fact, the most massive stars in the universe are able to undergo fusion until the primary thing left in the star is Iron (there can be no fusion past iron because the bonding energy per nucleon is greatest in iron; this is how we know that all elements with nuclei heavier than Iron's were created during supernovae). Though the process isn't fully understood (it's also possible that it is understood now and I just haven't read about it), these super-massive stars DO collapse after they're done burning into Iron. The thing is, though, with these super-massive stars, as a result of their rapid collapse they start emitting Neutrinos, and once the star isn't able to collapse any further, the star's remaining material rebounds and explodes outward again. This is what we know as a supernova.
Depending on the amount of mass left behind after the supernova, any number of things can happen. This is where we get neutron stars and black holes. I'm remembering the terms "electron degeneracy" and "neutron degeneracy" right now, but I can't remember where it fits into it all, to be honest. Something worth looking up for yourself if you're interested.
This post was edited by bentherdonethat on Jan 23 2011 01:37am