As a main sequence star nears the end of its life, it begins to grow or swell, using every last bit of stored hydrogen and helium for energy. As it does this, it begins to collapse on the inside. This either causes a supernova as it explodes from the stress, a black hole if it collapses on itself or the red giant will just decrease into a small, white dwarf.
As the star swells into a cooling red giant, the planets around it will burn, if not get sucked into the star by gravity. It's an, unfortunately, inevitable fate.