There needs to be more of a consequence for large companies who create platforms like this, then get a bunch of developers & users dependent on it, and then pull out the rug.
And not necessarily government regulations. Maybe a contract that guarantees operation for X number of years should become the standard, or even better, an explicit agreement to open-source discontinued products so the community can continue running them.
The usual excuse for not open-sourcing is that commercial products aren't developed in a vacuum. Flash, for instance, supposedly included a bunch of codecs that Adobe didn't have the license to redistribute as source.
At a bigger company, there are presumably dependencies on in-house build systems, standard libraries, etc. Maintaining open-source versions of those is unfortunately a non-trivial task.
You just make all the dependencies open source at the time the rest of it becomes open source, then you can keep the updates in-house and the community can update the dependencies if necessary and willing
That still assumes the dependencies are first-party. Some well known CVE examples have been how much both macOS and Windows had internal dependencies on Adobe code. Surely Adobe still has a commercial interest in their code even as/when both macOS and Windows dropped the features that relied on those dependencies?
(For other examples, the game industry is full of well known third-party "middleware" like Bink, SpeedTree, and much more because those middleware like to force their logos into places for advertising as a part of their licensing terms. If Windows had opening or closing credits it might be a surprise how many logos might be forced to show up in it.)
Ideally people (devs) would remember companies like that and avoid them in the future when they decide on which platforms to build their next project or which APIs to trust.
But in reality people (me included) will be annoyed today and forget it tomorrow, when a cool new platform is announced.
And not necessarily government regulations. Maybe a contract that guarantees operation for X number of years should become the standard, or even better, an explicit agreement to open-source discontinued products so the community can continue running them.