Now we have to get into "vested" definitions. If you are 100% vested, then the company's match is 100% yours. For example, if you put in $10000 and they matched $2500 at 100% vested, then that is your $12500 to do with as you please (within federal laws of course).
But, some companies have a vesting schedule. Meaning that if you leave early (fired or quit) then you only keep some of the match. All companies do this differently. For example, a company might have a 50% vesting period for say 3 years. If you leave during that 3 year period, then the company keeps 50% of that match. In this case, you'd keep your $10000 (it was yours to begin with), you'd keep half of the $2500 match and the company would keep the other half of the $2500 match. In total you'd leave with $11250. After the 3 year period, you would be 100% vested and you'd keep it all.
But that was just an example, the vesting amount and time duration vary a lot from company to company.