Sometimes companies are acquired by other companies. The way this works is that the target company's managers and board negotiate a deal with the acquirer, and then they call a meeting where the shareholders can vote on the deal. They book a big room, and the shareholders show up, and the managers say why the deal is good, and the shareholders discuss it for a bit, and then they vote. This is a real thing that actually happens. I went to one once.
But usually it is more complicated than that. Mostly, it is inconvenient for shareholders to show up at the meeting, so mostly they don't. Companies mail out proxy cards, and if you are a shareholder with better things to do that day, you fill out the proxy card and mail it back. The proxy card appoints someone who'll be at the meeting anyway -- typically someone who works for the company -- to vote on your behalf. You tell her how to vote, and then she does it, and it's as though you'd been there and voted yourself. You don't even have to pay postage; the company provides a self-addressed stamped envelope.