What determines what happens to as main sequence star as it spends time in the main sequence and what happens after it leaves the main sequence?.