Canadian troops capped a deadly and dangerous 12-year mission in Afghanistan on Wednesday, hauling down the Canadian flag at NATO headquarters in Kabul during a ceremony that was held under heavy guard.

"We were quite explicitly told today in Kabul that we could not even report on this ceremony until after it was done because of security concerns," CBC correspondent Paul Hunter said from Kabul on Wednesday.

Looking back at Afghanistan CBC News Network's Power & Politics and CBC Radio's The House will look back at Canada's mission in Afghanistan and whether it was a success. Listen to the House's special edition on Afghanistan on March 29 at 9 a.m. ET on CBC Radio One. Watch and take part in Power & Politics' special townhall edition on Canada's mission in Afghanistan on March 31 starting at 5 p.m. ET on CBC News Network.

"After all this time, they are still worried about security here in Kabul, and I'll tell you, the streets are filled with checkpoints and barbed wire and giant concrete blocks."

The ceremony, held under sunny skies, ended with Canadians involved in the NATO training mission leaving aboard a U.S. Chinook helicopter. The remaining Canadian personnel will leave by the end of the week.

Still, Canadian and allied dignitaries praised the country's involvement and sacrifices.

"Your strength has protected the weak; your bravery has brought hope to hopeless; and the helping hand you have extended to the Afghan people has given them faith that a better future is within their grasp," Deborah Lyons, the Canadian ambassador to Afghanistan told an assembly of the last 100 soldiers who served on a three-year training mission.

The war cost the lives of 158 soldiers, one diplomat, one journalist and two civilian contractors.

"We can wish that the families of the fallen do not lament their fate, but we know that this is not the case. The only small comfort comes from the knowledge that the sacrifices of lost loved ones has been worthwhile, that they made a difference, and that their grief is shared by a grateful nation.

Maj.-Gen. Dean Milner, the last Canadian commander in Afghanistan, says it's important Canada and the rest of the international community remain engaged to complete the work started during the war. (The Canadian Press)

"It is said that the only thing necessary for the triumph of evil is for good people to do nothing. Your actions and those of your fallen colleagues have stopped the triumph of evil."

Canadian commandos, hunting al-Qaeda, were the first troops to hit the ground in late 2001 and they were followed by as many as 40,000 more rotating through different campaigns, including the five-year combat mission in Kandahar.

Hunter reported that despite rampant violence, high levels of corruption and a strong drug trade, officials feel Afghanistan is a much different place from what it was in 2001, with a much stronger Afghan army.

British Lt.-Gen. John Lorimer, the deputy commander of NATO in Afghanistan, said the Canadians "repeatedly proved their courage and capability" alongside coalition and Afghan troops, especially in Kandahar "where you not only fought hard, but you fought smart."

'Mixed emotions'

Calling it the end of a significant era, Lorimer said he viewed the departure of the Canadians with "mixed emotions" given the shared experiences of the last 12 years.

"I am sad to see you return home, yet grateful for the opportunity to have served alongside such great Canadian leaders along the way," he said.

The last Canadian commander, Maj.-Gen. Dean Milner, said the progress made is not irreversible and the West needs to continue nurturing both military and civilian institutions.

Milner told CBC News Network that the country is on the right track with security forces that will ably handle the country's upcoming elections.

"It's a capable Afghan national army and police force that's getting ready and absolutely capable of dominating a resilient Taliban force," he said.

Lyons said Canada will remain engaged in Afghanistan and the focus will be on helping build the ruined nation's economy, particularly in the resource sector.

Similar flag ceremonies were planned for today in Alberta, Saskatchewan and New Brunswick.