Right now, Any felony and drug related/voilent misdemeanors will strip your 2nd amendment right from you. So if a mentally unstable person has a history of violence, they already cannot own a gun.
If this was the person's first violent action and it was with a gun, it couldn't have really been stopped. That's all the more reason we should try to help all mentally ill people and not just restrict rights from the ones we think are dangerous. Especially considering that the recent shooting from mentally ill people didn't purchased the guns they used anyway. In both cases they were stolen.
Criminals don't follow laws.