What happens when a socio's owned club is sold ?

A question came into my mind. As the title suggests what happens when a clubs like Barcelona or Real Madrid are sold or go private. Are the Socis paid the amount equally ? The Socis keep on changing as new members are added each year and some members do not renew. So how do they determine who gets the money in that case.