When a company get’s sold then it depends on what the agreement is between the company and the company buying them out.
You will not just lose your stock. If another company is buying them out you will either get new stock in the new company or you will get money for your shares.