If you have a time machine you can figure out how best to stop this,
Hit them over the head with a baseball bat as they walk out their front door.
Nobody expects that (usually).
But without trying to sound crazy, I don't think that may stop it.
There seems to be a pattern in all these recent shootings where they happen at "just the right time" politically (including the shooting of the congressmen at the baseball game).
The "shooter" always just so happens to have been someone deliberately ignored by the FBI/Law Enforcement despite lots of warnings and pleadings from local people and concerned citizens that this person is crazy & going to do something bad.
They seem to be given all the time they need to kill as many as possible till they run out of ammo, kill themselves, call it a day and go get a burger etc before suddenly LE is all over it (when the whole time they are doing nothing to stop it).
Then of course after the killer has murdered a whole bunch of folks.
THEN when they KNOW it's safe, all of the sudden, the big strong brave police force are all happy to line up with all their tacticool gear and point weapons at terrified survivors, screaming at them and terrorizing them all over again and making them walk around like criminals with their hands up just to put that extra hurt on them. After cowering behind their RVs when the actual bad guy was doing stuff.
I have a very hard time believing that all these acts are just random and the pitiful response to it is also totally organic.