Somebody always owns the rights. Generally if the current owners go bankrupt, the rights go to their creditors, who usually sell them to someone else. Other times, a company is purchased or merged before the actual bankruptcy occurs. In extremely rare cases, a work can actually enter the public domain, but that's almost always because something wasn't registered properly, or the owners released it as freeware intentionally before they folded. However, there are often cases where the rights are owned by multiple parties, in which case GOG (or anyone else) has to get agreement from everyone in order to re-release the game.
So a company going under doesn't necessarily mean that GOG can't get the games. It can, though. When Sir-Tech folded, the rights to all the Wizardry games got passed around, and are now owned by a Japanese company that has no desire to release them on GOG. Other times, a company going under can make it easier for GOG to get the game, because the rights could be purchased by a someone who already has a deal with GOG.