Some state plans will only allow you to pull out the gains as a proportion of the total balance. For example you pit in 10k, it grows to 11k, bit when you pull out 10k they will assign 909 of the withdrawal as gain and the other 9,091 as principal. They would also recapture any tax benefit you had on the contribution as well as penalties.