Communicate. Really, "terrorists" usually have the same goals as "we" do: peace, respect, safety, prosperity. If we stopped pretending that "we" are right and "they" are wrong, the problem might go away in the long run. Note that I do not approve of the terrorist approach to communication but, maybe, they just have no other way of making themselves heard, so if we listened, they might start talking instead of bombing…
If you blow up people waiting in line in an airport, going to a concert, or visiting a nightclub, you are dead wrong. There is not much wiggle room here.
If everyone who feels they are don't have a way of making themselves heard (whether or not that thought is valid) just starts harming unrelated people, we can just do away with society completely.