As an aging red supergiant becomes more and more luminous, the outer layers puff out more and more. It gets to the point where the star loses gravitational hold on its outer layers and they get pushed away the pressure exerted by the stellar wind and by the photons leaving the core. (Yes, light can exert a pressure!)
These shed outer layers are called a planetary nebula. As this planetary nebula continues to drift away, it becomes a part of the interstellar medium.
What is left behind is a degenerate core made of carbon and oxygen. There's not enough mass in the core to collapse the core any further. It will therefore never be hot enough to fuse carbon or oxygen to make any heavier elements.
This hot ball of carbon and oxygen, held up by degeneracy pressure, is called a white dwarf.
If there is a largen enough companion close by, the white dwarf may
gravitationally attract matter away from the companion and become an
accreting white dwarf. If there is no
binary companion, or if the companion is too small or too far away, no
accretion will occur, and it will be a lonely