I don't know what the contract looks like; doesn't Germany have a legal obligation to pay Russia even if it were to stop LNG imports?
Failing that, the German government could just change the law to disallow the contract. Russia could ask for a binding(ish) decision from the international community, but this is one of those situations where I doubt the decision would go in their favor even if they were in the right legally.