Like the Sun, these medium-sized stars are yellow because they have a medium temperature (remember the fire example?). Their higher temperature causes them to burn their fuel faster. This means they will not live as long, only about 10 billion years or so. Near the end of their lives these medium-sized stars swell up, becoming very large. When this happens to the Sun, it will grow large enough to engulf even the Earth. Eventually they shrink again, leaving behind most of their gas. This gas forms a beautiful cloud around the star called aPlanetary Nebula.
When will the Sun expand into a giant, and then shrink leaving behind a planetary nebula?
Don't worry, the sun is only about 5 billion years old. It still has another 5 billion years or so before it will expand and turn into a planetary nebula.
The Sun is so hot that when it dies, it will take a long time to cool off. The Sun will die in about 5 billion years, but it will still glow for many billions of years after that. As it cools, it will be what is called a white dwarf star. Eventually, after billions, maybe even trillions of years, it will stop glowing. At that point it will be what we call a black dwarf star. Because the process for a star to become a black dwarf takes such a long time, it is believed there are still no black dwarf stars in the universe.