You don't necessarily get shares from the purchasing company. I've had companies buy out another company and payout the shareholders entirely in cash at the per-share buyout offering price. I've also had non-publicly traded companies buy a publicly-traded company and take it private, which also results in cash for your shares.