Editor's note: Rep. John Boehner (R-Ohio) has been Speaker of the House since 2011. You can follow him on Twitter @SpeakerBoehner. The opinions expressed in this commentary are solely those of the author.
(CNN) -- Three weeks ago, I had the privilege of visiting our civilian leaders and military commanders, as well as our troops, in Afghanistan. It was my fourth trip to the country and a vastly different one than my first visit in 2007.
Flying over Kabul at night, I was struck by the changes: Electric lights and even traffic are visible throughout the valley. I was encouraged by what I saw and by what I heard from Ambassador James Cunningham and General Joseph F. Dunford, Jr.
The Afghans are taking the lead for their own security, and now they are poised to successfully transition to a new government for the first time in their history.
After 13 years, I am often asked why Afghanistan still matters. The world is growing more complicated by the day, and, in my view, more dangerous. The responsibility is on leaders in Washington to remind the American people why finishing the job right in Afghanistan remains important.
The explanation is straightforward: Not only was it the location from which the 9/11 attack that killed 3,000 Americans was planned, but the country also remains uniquely vulnerable to becoming a terrorist stronghold again if we don't complete our work to empower the Afghan people, security forces and government to protect their own country.
Our mission quite simply is to prevent another terrorist attack.
And, there's another reason we don't talk about much, but it remains equally important. Both friends and foes are watching to see whether America has the resolve to complete its task or if we will fall short of our mark out of fatigue or political expediency. This has ramifications not just for Afghanistan but other critical areas where America has strategic national security interests.
Make no mistake, Afghanistan remains a tough fight. The progress has been significant, but the country will continue to have setbacks. Violence, like the recent tragic shooting at a Kabul hospital, is going to continue. Terrorist organizations will continue to attempt high-profile attacks to break our resolve.
But because of the courage and sacrifices of our deployed men and women, both military and civilian, I am optimistic that we can achieve our mission successfully if Washington doesn't squander this progress.
At the time of my visit, I said that I hoped Washington and Kabul would always be worthy of the shared sacrifice and effort that our troops, the international community, and the Afghan people have made. The biggest takeaway from my visit is that of all the challenges facing our strategy for Afghanistan, the most potentially damaging and completely avoidable is quitting just short of the goal line.
It's essential that we do not repeat the same mistakes in Afghanistan that we made in Iraq. Before the end of this year, the Obama administration must reach a bilateral security agreement with the Afghan government that reinforces our commitment to the Afghan people and its security forces.
With input from our commanders on the ground, this will likely require retaining a credible, residual troop presence to help continue to thwart terrorist networks as well as provide appropriate levels of training and advice to the Afghan security forces as they continue to grow and mature into an effective, independent fighting force.
As a former small business man, I like an analogy I heard on our efforts to train and assist the Afghan Security Forces: we've helped them open for business, and now we need to ensure they have the processes and logistics in place to stay in business. Our military has a clear, understandable plan to put themselves out of business at the end of this process.
There is a shared, bipartisan legacy in Washington for Afghanistan. I am convinced history will judge both the executive branch and the legislative branch not on whether we ended wars, but how we ended them.
It is increasingly apparent that the United States left Iraq too soon, and it is with heavy hearts that we see the black flags flying in areas of Iraq where the United States expended our most precious treasure, the blood of our fellow citizens. We cannot let that happen in Afghanistan. A bilateral security agreement is critical if we're going to successfully complete the work that has been accomplished to date and to help ensure that the gains we have made are not jeopardized like they have been in Iraq.
America's foes, both state and non-state actors, are watching with great interest how we leave Afghanistan, watching to see whether we leave after securing our interests and honoring our commitments, or if we just leave.
And over the last year, our commander-in-chief has often talked more about leaving Afghanistan than how we are going to achieve our mission. We all want to bring our remaining troops home as soon as possible, but succeeding in Afghanistan is vital to our national security interests and it must take priority over any calendar dates. The President has an obligation to better make that case to the American people. And if he does, I will support him.
For more than a decade, our troops and civilian personnel have fought to bring peace and security to Afghanistan -- and to ensure it can never again be used as a safe haven for terrorists to attack the United States. Many Americans have sacrificed to secure these goals, and far too many have lost their lives or suffered life-altering wounds.
Washington and Kabul must work together to secure the gains we have made together and complete our mission.