How can stars create crystals?
Regular stars like the Sun remain gaseous because they have a nuclear source of energy. But when the Sun dies it will become a large red giant star for a short time, and then a compact white dwarf made of carbon and oxygen, corresponding to the inert nuclear waste of helium burning.
Without any source of energy white dwarfs are bound to cool over timescales of billions of years. After a few billion years of cooling the liquid interior abruptly transitions into a solid, which slows down the evolution. It is much like if you were doing the experiment on freezer water. If you used a thermometer you would realise that it remains at the same temperature for a while before it cools down more rapidly. This is because latent heat, or transformation energy, is released during solidification.
The same happens in white dwarfs where the freezer is the dark and empty universe, but the transition happens at ten million degrees because of the densities involved. The atoms are ordered in a cubic lattice because it minimises the potential energy. The thin surface layers of the white dwarf (less than one per cent of the mass) will remain gaseous for another 10 to 20 billion years until they reach room temperature. After that, the white dwarf is a fully solid crystal and stable for at least
10 to the power of 20-times the current age of the universe!