Mastodon servers let you migrate your account to another instance, and admins are supposed to give users 3 months of advance warning in case of shutting down.
There are plans to add a feature like this in a future version of Lemmy. For now, there are scripts that let you migrate your settings and subscribed communities.
That sucks, but hopefully something good can come out of it eventually. Like better mod tools...