Excellent question!
Somewhat like a layer cake, stellar interiors are made of of zones in which convection takes place, and zones in which convection DOES NOT take place. Effectively, the non-convective zones prevent the escape material deeper within the stellar interior. Energy transport through the non-convective zones is achieved by radiative energy transport, and the governing factor that determines whether or not a particular zone is convective or non-convective is it's opacity. The opacity is directly related to the temperature gradient within a zone, and if the gradient is less than the adiabatic lapse rate, there's no convection.
This, BTW, explains why stars never utilize more than a tiny fraction of the total hydrogen present in nuclear fusion reactions: most of the hydrogen in the star exists outside the the zone in or near the core where conditions for hydrogen fusion are met, and have no way of getting into these zones because the hyrogen and fusion byproducts within the nuclear reaction zones have no way of getting out. Thus the the helium "ash" remains in the core region, and does not float to the surface of the star.
Thanks for the education!