Some times we question God's methods. Authors in the Bible portray God's judgment and it's puzzling behavior for a loving God.
God's actions though were to prevent evil from spreading because people had turned from Him. God determined to stop their influence. His judgment did not mean that grace had been removed.
God is quick to forgive if we humble ourselves.
Sometimes, as parents, we punish our children out of embarrassment, tiredness or stress. This punishment is therefore motivated out of our own personal and human need.
God though is never tired, stressed or needy. His discipline is simply and merely for our benefit as much as we struggle with this. As written in Hebrews 12:10, "Our fathers disciplined us for a while as they viewed best, but our Father disciplines us for our benefit, that we can share in His holiness."