The middle eastern nations are prone to be left on their own and that breeds anger and a sense of being on the outside. It could not hurt to include the nation of Turkey in the EU and have a sense of inclusiveness. That might engender a sense of solidarity and talks with it and with other nations that would ease terrorism threats.
Where there's a will, there's a way. Terrorism, especially post-9/11 terrorism, seems defined by its utility of makeshift weaponry and elusive tactics, and no amount of resource gathering and collective planning is going to be able to pin down every basement bomb maker, back alley planner and disgruntled person wishing for upheaval.