The star is only on the main sequence while hydrogen is turned into helium in the core. Eventually all the hydrogen in the core will have been converted into helium. The star is no longer in equilibrium because the rate of energy production decreases. The force of gravity cause the core to contract. This contraction increases the temperature of the core and helium fusion becomes possible. Though the core contracts, the outer layers of the stars expand and cool. The star becomes a Red Giant. The radius of a newly formed Red Giant may be 400 million km. Compare this with the present radius of the Sun – about 700,000 km – and the Sun Earth distance – 150 million km. Hydrogen burning moves to a shell around the core. This may happen several times – with nuclei burning to produce successively heavier nuclei and the burning of lighter nuclei moving to a shell, eventually producing an onion like structure. With the formation of each shell the star expands further, eventually maybe up to 700 million km. If the star has sufficient mass, heavier elements up to iron may form.
The process of fusion must come to an end with the production of iron, since energy can not be released by fusing iron to form heavier elements: Iron has the greatest binding energy per nucleon of all nuclei. The star cannot continue to shine.