Cooling of magnetic flux tubes as a mechanism for suppression of magnetic buoyant escape of the flux tubes from the sun and stars