Human nature is such that when we are threatened, whether the threat is simply perceived or real, we will either flee or fight.
Terrorism is the response from some people that choose to fight when they are threatened. To stop terrorism, you either have to remove the threat to the terrorists or remove the desire to react with a fight. Since the threat is sometimes simply a perceived threat that isn't actually real, that can be difficult. Since the desire to fight is ingrained into one's DNA, that is also really tough to stop.
The only true way to defeat terrorism is to defeat it from within. You have to change the minds of the potential terrorists by either removing what they perceive as a threat or by removing their desire to react by fighting (or hopefully, both).