Well and good, but...The mentally unstable individual takes his new, shiny AR-15 out of the closet, and steps into the school down the street. Those teachers and students have rights that are being infringed by the individual whose guns were not taken away because he has 2A rights. It just isn't as easy as saying "shall not be infringed". If we support and defend the Constitution, we have to support and defend the entire Constitution. The "gun problem" in USA is because there have been those who have taken advantage, either intentionally or unintentionally, of the freedom and easy access to firearms.
I don't have a solution, but ignoring the issue and saying that 2A is supreme over all is not a solution either.
In your scenario, the rights of the teachers and students have been infringed by government that is denying them of their RKBA to effect a viable defense. The mentally unstable person cannot infringe upon the rights of anyone. If the mentally unstable person is known to be unstable and dangerous - as would be the case in your scenario - that person should be confined in an institution upon findings after due process. That is the solution you are looking for. The same applies to violent felons. Violent felons should be incarcerated(if not executed) until it can be proven they are no longer a danger to be armed out in society. That's how you do it without infringing upon anyone's RKBA.
Woody