So we know that Earth probably won’t survive the sun expanding into a red giant, and even if the planet itself does, any life certainly won’t. The sun will stay a red giant for about a billion years. After that, if Earth is still about, it’ll have to deal with the next phase of stellar evolution: the sun becoming a white dwarf.
By this point, the sun will have burned all its helium and turned it into carbon. It won’t be hot enough to burn the carbon, so it’ll collapse, like when it ran out of hydrogen. This will cause it to release a bunch of energy, and the outer layers of the star will expand even further and become unstable. It’ll keep throwing off layers and losing mass until all that remains is the core. It’ll take about 75,000 years for the layers to disappear and the sun to take form as a white dwarf.
As a white dwarf, the sun will be much smaller than it is now – about the size of Earth itself – but still with about half the mass it had as the sun we know today. This will make it super dense.
It’ll also be much dimmer than it is now. The temperatures on any remaining planets in the solar system will drop as the amount of energy they get from the sun drops too.
At this point, the sun is basically “dead”, but it’s still hot. Eventually, the sun will lose enough heat so that its temperature matches the background temperature of the universe – it becomes a black dwarf.
Right now black dwarf stars are theoretical, but only because the universe has not been around long enough for any to exist yet.