I'm imagining some world where patent troll-equivalents crawl the web for abandoned experiments that could serve as fodder for lawsuits. I agree with the sentiment that companies shouldn't brick products with code changes but worry about the downstream effects.
Thing is there's is already plenty of open source code out there written by people of very varied means. As far as I know patent troll like behavior is not a major problem for open source, so I don't see why it would magically become the case.
I'm not saying that the behavior Sonos engaged in here is good - I'm just saying that jumping to "it should be illegal" so quickly without considering all of the secondary impacts is a mistake.
Practically speaking it costs time and therefore money to do this. Small companies can't be expected to have both the technical and legal resources on hand to ensure compliance in the event of an EOL event for an API.
The cost to do the work and the cost to ensure compliance with the law would both be real dollar amounts for most small companies. Enough that if you wanted to try out an experimental new service you'd have to take into account that cost in your budgeting.
Telling a company (or individual) that they need to sit down and pay to kill their products means they will think harder before they launch them. That's a barrier, and it will slow down innovation and make sure that only the companies with the resources to support compliance and open sourcing will be the ones to launch new services.