When our sun reaches the end of its lifetime , it will turn into a red giant. How long will it be a red giant, and what happens after a star has been a red giant? Does it turn into a planet after a long enough time spent, when it has used up all its helium?
The Sun, and any red dwarfs above about 0.25 solar masses, will expand into what's called a red giant, a late stage of stellar evolution. At this stage, the star starts to fuse different elements, and eventually throws off its layers as a planetary nebula, leaving behind a white dwarf made of carbon and oxygen.
A red dwarf that is too small to become a red giant will not turn into a planetary nebula: its fusion processes will eventually cease and it will probably produce a white dwarf made mostly of helium. But the main-sequence lifetime of these very small stars is longer than the age of the universe, so this has never actually happened yet. The helium white dwarfs that do exist were formed in binary star systems (and were formed during their complex dynamics).
Red dwarfs are small main sequence stars - the smallest and dimmest that are still able to fuse hydrogen in their core. Brown dwarfs are even smaller (in terms of mass), but cannot even fuse hydrogen - they are thought to be able to fuse deuterium and lithium. Stars smaller than a brown dwarf turn out to be gas giants like our Jupiter, Saturn, Uranus and Neptune.