When a star like our Sun reaches the final phase of its life, it burns out its supply of hydrogen and it begins to cool down and expand. This phase is called a red giant. The core begins to contract until it starts burning helium and heats up again to eventually produce larger elements like carbon and oxygen through fusion reactions. When the core starts producing iron, this is the largest atom produced by a star. At this point the outer layers begin to be stripped from the star and become a nebula. Once the core has finished burning itself out, what it eventually becomes depends on its mass. Smaller cores will become white dwarfs. Larger cores can eventually explode, a process called supernova. The result of this explosion is either a pulsar or a black hole if the star was massive enough. A black hole is when the core becomes so dense that its gravity causes it to collapse in itself so that nothing can escape it (including light). Our Sun is relatively small on the scale of stars so it will most likely become a white dwarf in a few billion years.
Our sun will run out of hydrogen fuel and then start fusing helium, which in turn creates a red giant. After fusing all remain fuel, the star has a minor expansion where the outer layers are thrown into space and the core collapses to make a white dwarf which becomes a brown dwarf then a black dwarf.