As Spain found out the hard way, staying in or leaving Iraq doesn't make a bit of difference to the Jihadis. In fact, after promising no more attacks in Spain if they would just withdraw, Al Qaeda has continued to be active in Spain declaring that: "We will not be in peace until we set our foot again in our beloved al-Andalus" just a little while ago. In other words, its not over until Spain is an Islamic nation ruled by Sharia. In fact, its not over until all the world is part of the Dar-El-Islam, the Caliphate is established, and all the non-muslim apes and pigs are subjugated or eliminated. As such, there is no "end date" for what we incorrectly call "the war on terror" from the Jihadi perspective it goes on until total victory is achieved. So Western nations withdrawing from here or invading over there will never end the conflict, the only value these actions have is as they help or hinder one side or the other.
Now as far as the non-Muslim nations are concerned, from 611 to about 1700 we had a period of constant war with the Jihadis as Islam started and then massively expanded throughout the Middle East, Near East, Indian Subcontinent, Eastern Europe, Iberian Peninsula and Africa via wars of conquest and through the Pacific via trade and alliances. Generally speaking, once those areas were integrated into the Dar-El-Islam, they never left it. At several points, Western Europe was almost conquered by the Islamic Jihad. From 1700 to the mid 1900s we enjoyed a brief respite because, for the most part, Islam was not present in the West and the Western powers were essentially "sitting" on the Islamic world, both by propping up the Ottomans (who provided the illusion of caliphate and the suppression of pan-Islamic radicals) and colonial rule. That situation changed dramatically with the end of the Ottoman Empire and Western colonial rule and the beginning of reverse colonization via Islamic immigration into Europe and the United States from these former colonies. In essence, we hit the pause button on the Jihad for about 200 years, but now the "PLAY" button has definitely been pressed and is even more dangerous because the Jihad is now being waged mostly via "asymmetrical" warfare, and utilizing fully what they perceive as our own weaknesses and we would call “civilization, ethics, and the rule of law.”
Leave Iraq or stay, leave Afghanistan or stay, the war will continue because it is an integral part of the comprehensive ideology that is Islam. Peace for them is achieved through complete victory, hence the Al Qaeda statement that there will not be peace in that area until Spain ceases to exist as Spain and become Al-Andalusia once again. As such our options are contain, eliminate or convert. Co-exist is not an option they offer. Personally, I don’t believe we have the will or the ability to do any of these, so it’s going to be a very difficult and horrifying century to say the least.