Nip Something In The Bud

to correct a situation before it becomes a problem

Examples:

  • You should nip that bad habit in the bud.
  • The police nipped that riot in the bud. Thankfully nobody was injured.