Once the red giant of a star less than 1.4 solar masses has used up all its fuel, fusion stops and the core contracts as gravity becomes the dominant force. The outer layers are thrown off, forming a planetary nebula, and a very dense white dwarf forms, which will eventually cool to form a black dwarf.