Hashem does not desire to punish. The Midrash says Sodom was warned for years before it was overturned, and Yechezkel said, “Return, and live.” As the Vilna Gaon and Rav Huna show, a punishment can be removed once a person regrets the deed and takes upon himself not to repeat it.