It is not clear if background checks can prevent this type of event.
That would pretty much guarantee that people who need mental health services would deliberately avoid getting it to prevent it from showing up on their records, e.g. a security guard who needs to carry a firearm for their job.
Uh, what do you think a psychiatric exam is? There's no crazy-o-meter that they stick into an orifice to objectively determine whether you're mentally ill or not. You simply get asked a series of questions which you can reply to in any way you like.
"socially awkward people aren't allowed to have guns" as a policy would be a flagrant violation of a constitutional right.
The scary thing is that mentally ill people can intentionally mask their illness in order to pass exams.