Requiring an "end of life plan" in the ToS would be a start.
Or allow the community to build and host reverse engineered servers after your game is dead. Don't go out of your way to sue and destroy community efforts.
You realize that APIs can be reverse-engineered and new clean-room servers created? It has been done for a bunch of old games.
For indie games, would an exclusion like "games with less than 1 million lifetime players" be enough? That's not an unsolvable issue, especially as indie games are not the main games people are worried about being killed. Most indie games will not be 'killed' by the developers because they're not releant on servers that the developer cannot afford to host.
Lots of indie games I see just use the storefront's APIs for multiplayer matching, not even requiring a matchmaking server.