The Sun is going to die in a blaze of beauty.

We can't know exactly how this death will look, billions of years into the future, but the deaths of other stars like the Sun give us a glimpse into how this spectacular process might unfold.

One such object is the subject of a new image from the Hubble Space Telescope. Its name is NGC 2438, located roughly 1,370 light-years away, and it's what is known as a planetary nebula.

Planetary nebulae have nothing to do with planets; they're so named because they looked a bit like planets when viewed through early telescopes. That's because they're roughly spherical – huge clouds of gas ejected from a dying, Sun-like star.

hubble wfc3 image ngc 2438 insetHubble's new image of NGC 2438. (NASA, ESA, K. Knoll/NASA Goddard, S. Öttl/University of Innsbruck, et. al.; Gladys Kober/NASA/CUA)

When the Sun nears the end of its lifespan, running out of hydrogen to fuse in the core, the core will start to cool and contract – disrupting the delicate balance between the inward pressure of gravity and the outward thermal and radiation pressure generated by core fusion.

This will bring additional hydrogen in from the region around the core, which will ignite in a shell around the core. This will create a great deal of energy, causing the outer layers of the Sun to puff up into a huge, bright object that may reach as far as the orbit of Mars.

Eventually, its instability will cause a series of eruptions that eject a large percentage of its mass into the space around it. The stellar core will collapse into a white dwarf, shining brightly with residual heat and lighting the ejected material from within.

This is the planetary nebula, the stage at which NGC 2438 is at now. This is a very brief stage in the star's lifespan, lasting only about 10,000 years; the ejected material is continuing to expand into space, and will eventually become too tenuous to be seen. Each element in the image is color-coded: blue represents oxygen, green is hydrogen, orange is nitrogen and red is sulfur.

ngc 2438 infraredAn image of NGC 2438 obtained using the Schulman Telescope in 2012-2013. (Adam Block/Mount Lemmon SkyCenter/University of Arizona)

NGC 2438 is also interesting because of the glowing "halo" that surrounds the inner ring of the nebula, a feature seen in many round planetary nebulae (but not the new Hubble picture). A study that included NGC 2438 found that the halo is excited by ionizing radiation from the star itself that causes the gas to glow.

The material surrounding NGC 2438 is expanding at a rate of around 37 kilometers (23 miles) per second. In another few thousand years, give or take, it will be too thin to be seen. Meanwhile, the Sun has a lot longer to go; its transformation into a red giant will begin about 5 billion years from now.

If any humans are around to see it, they'll be doing so from what we hope is a very safe distance.