Most classes cover the importance of avoiding having to use your gun, if possible.
I took a short class from Andy Stanford at a conference once and I recall this was the major emphasis of the class. The class included some gunfighting stuff, but most of the material was on what he called 'verbal judo', trying to manage the situation nonviolently and de-escalate it if possible. Tools covered included being aware, body language and "the fence" posture, hardening up your response with a friendly "no, thanks" when approached in say a parking lot, all the way up to screaming "BACK THE eff OFF!" if the other steps don't work. (assuming also there's time, and also note it's telling the guy to back off with profanity, but not calling him an eff-word name which would escalate things). He referenced Southnarc's "Managing Unknown Contacts" extensively, which would be an even more direct link to the source for training on this issue.
I haven't been able to find one of his (Stanford's or Southnarc's) classes near me since, but that was some of the most useful stuff for a non-fighter like me to learn.
Also, I recommend the book "Facing Violence" by Rory Miller. Being a book, it's not a training class, but I think it's aimed squarely at the what you're talking about including what to do if you're unable to keep it from turning into a fight or an attack.