The picture shows the Helix Nebula NGC 7293, the nearest planetary nebula.
When a star like our Sun comes to age, having long burned away all the
helium in its core in its main sequence phase, and also (in the consequent red
giant stadium), the helium to carbon and oxygen, its nuclear reactions come to an end in
its core, while helium burning goes on in an outer shell. This process makes the star
and causes its outer layers to pulsate. It becomes more and more unstable and loses
mass in strong stellar winds. The instability finally causes the ejection of a significant part of the star's
mass in an expanding shell. The stellar core remains as an extremely hot, small central
star, which emits high energetic radiation.
The expanding gas shell is excited to shine by the high-energy radiation emitted from the central star. The material in the shell is also accelerated so that the expansion gets faster over time. The shining gas shell is then visible as a planetary nebula. In deep exposures, the matter ejected in the early stages can be detected as an extended halo surrounding many planetary nebulae.
Below an artists rendering for the solar system 5 billion years from now.