This is the question I propose. So much focus is always on how we destroy the terrorists/organizations that already exist. So little focus is on how we prevent future recruitment.
It can't be done.
Terrorism is a tactic of the weak, who are unable to achieve their goals either by legitimate means, or by large-scale use of force.
Terrorism also doesn't work. The terrorist group loses momentum, or the issues become less critical, or the group goes one step too far for even its own supporters. If they ever get big enough to actually hold territory, that usually makes them large enough to be vulnerable to conventional military tactics.
IRA, FARC, PLO, Shining Path, Weather Underground, Tamil Tigers: Fail, fail, fail, fail, fail, fail.
We also live in a world were any lone idiot can proclaim "LONG LIVE THE IRA!" and shoot 2 people, and voila it's a "terrorist attack," even though it's actually a mass shooting.
One solution is to defuse the political tensions. Of course, once you manage to do that for one group, another major issue is likely to crop up, and eventually some idiot gets the brilliant idea to chuck a bomb in the middle of a crowd, and everyone runs around like a freaking maniac. Which is exactly what the terrorists want.
The other alternative is to realize that terrorism is sort of like drunken driving, or car accidents, or cancer. We can get rid of the vast majority of it, and safeguard things that are really important. However, we won't get rid of it all, and again since panicking and attention is what the terrorists are really after, deny it to them.