Intellectual property is an asset for the company. It’s treated the same as real estate or physical property. The majority of the time, all of the company assets get sold at auction.
If the company goes into bankruptcy, all assets are liquidated and sold for a fraction of their value at auction. This includes any intellectual property assets that are in the company’s name. Anyone has the opportunity to participate in the auction and purchase the IP.
A similar type of sale happens when the founders of the company voluntarily dissolve the company. If the founders do not have an agreement for ownership retention, then the IP gets sold with the other assets.
On a rare occasion, a company will close without selling the intellectual property. In this situation, the ownership is acquired by the shareholders. However, this is rarely documented and often transferred incorrectly.