All stars begin as clouds of dust that collapse and form heated cores. As stars reach the end of their lives, they can become white dwarfs after releasing all their energy in the red giant and planetary nebula phases. Alternatively, if a star's internal pressure can no longer counter its own gravity, it may explode as a supernova. The final phase of the heaviest stars occurs when they crush under their own gravity and form black holes that consume everything near them.