A Canadian man, his American wife and their three young children have been released after being held captive for years by a network with ties to the Taliban, U.S. and Pakistani officials said Thursday.Pakistan’s army secured the release of Joshua Boyle and his wife Caitlan Coleman, who were abducted five years ago while travelling in Afghanistan and had been held by the Haqqani network.U.S. officials had planned on moving the family out of Pakistan on a U.S. transport plane, but at the last minute Boyle would not get on, the official said.Another U.S. official said Boyle was nervous about being in “custody” given his background. Boyle was previously married to the sister of Omar Khadr, who spent 10 years at Guantanamo Bay after being captured when he was 15 in a 2002 firefight at an al-Qaeda compound in Afghanistan.A Canadian man, his American wife and their three young children born during the couple’s five years in captivity were freed in a Pakistani commando raid and shootout, authorities announced Thursday.The Pakistani military said Joshua Boyle, his wife Caitlan Coleman and their children had been freed in “an intelligence-based operation” after they’d crossed the border from Afghanistan, where they had been abducted by a group with ties to the Taliban.Tariq Azim Khan, the country’s high commissioner to Canada, said once the military received word of the family’s whereabouts from U.S. intelligence authorities, they acted quickly.Khan described a dramatic scene in which gunshots rang out as the family was intercepted by Pakistani forces while being transported by their captors in the trunk of a van.Intelligence officials in Pakistan said the confrontation happened near a road crossing in the Nawa Kili area of the district of Kohat in northwest Pakistan.“We know there was a shootout and Pakistan commandos carried out an attack and rescued the hostages,” Khan said from London.Canada’s Foreign Affairs Minister Chrystia Freeland, who has met with the Boyle family in the past, said they had endured an “absolutely horrible ordeal.” Freeland refused to describe the circumstances of the release, citing security reasons but said Canada had been working with the U.S., Pakistan and Afghanistan, whom she thanked.“We all have to really remember what a traumatic experience this family has gone through – really unspeakable,” Freeland said in Mexico City.Boyle and Coleman, who was pregnant at the time of the abduction, were held by the Haqqani network, a group U.S. officials call a terrorist organization.Boyle’s parents, who live in Smiths Falls, Ont., said their son and his family intend to come to Canada.“The family has chosen Canada,” Patrick Boyle said Thursday evening. “We’re hoping to know ourselves when we get to go pick them up.”The family were safe but exhausted, Patrick Boyle said.“We just spoke to them again recently, Boyle said. “He (Joshua) said they’ve all been up since Tuesday so he was very pleased, he’s running on empty.”In anticipation of the release, Canadian authorities had travelled to Smiths Falls and woke Boyle up early Thursday morning to give him the news.“They’d been in a hotel two minutes down the street for the better part of the day, waiting for approval to tell us they’d been released,” Boyle said.“We got a call at one a.m. saying ‘we’ll be at your door in five minutes and it’s not bad news.”‘He said he and his family were “over the top” Thursday at word of the release.“We struggled with every dark spot in the last five years, today that’s sort of parked,” he said.Joshua’s mother Linda had no doubt what the first thing she intended to do when she sees her son and family.“Hug them, slobber kisses all over them,” she said. Related content:Timeline: Captivity of Joshua Boyle and his familyColeman’s parents, meanwhile, posted a statement on the door of their Pennsylvania home saying they appreciated “all the interest and concern being expressed at the joyful news that Caity, Josh and our grandchildren have been released after five long years of captivity.”A U.S. national security official, who wasn’t authorized to discuss the case publicly, said the family were together in a safe location in Pakistan. American officials had planned on moving the family out of Pakistan on a U.S. transport plane but Boyle refused to board, the official said.Another U.S. official said Boyle was nervous about being in “custody” given that he was previously married to Zaynab Khadr, the sister of Canadian Omar Khadr, who spent 10 years at Guantanamo Bay after being captured when he was 15 in Afghanistan.Officials discounted any link between that background and Boyle’s capture and Freeland stressed that Boyle was not the focus of any investigation.Patrick Boyle suggested it was a matter of principle because his son was told the plane would have stopped at Bagram air base in Afghanistan, which American authorities had once used to ship detainees to its Guantanamo Bay prison in Cuba where many languished for years under harsh conditions.“I just think he just saw it as unnecessary and philosophically he finds it offensive,” said Boyle, who added that his son was effusive in his praise of his rescuers and is eager to cooperate with authorities and bring his captors to justice.The release came nearly five years to the day since Boyle and Coleman lost touch with their families while travelling in a mountainous region near the Afghan capital, Kabul.The couple had set off in the summer 2012 for a journey that took them to Russia, the central Asian countries of Kazakhstan, Tajikistan and Kyrgyzstan, and then to Afghanistan. Coleman’s parents last heard from their son-in-law on Oct. 8, 2012, from an internet cafe in what Boyle described as an “unsafe” part of Afghanistan.The couple appeared in a series of videos beginning in 2013, which were shared online. In one posted last December, the pair urged governments on all sides to reach a deal to secure the family’s freedom. Boyle’s parents had said the clip marked the first time they had seen their two grandchildren.They have said it was heartbreaking to watch their grandchildren observing their surroundings while listening to their mother describe how they were made to watch her being “defiled.”“It is an indescribable emotional sense one has watching a grandson making faces at the camera, while hearing our son’s leg chains clanging up and down on the floor as he tries to settle his son,” the Boyles said in a written statement at the time. “It is unbelievable that they have had to shield their sons from their horrible reality for four years.”The parents said their son told them in a letter that he and his wife tried to protect their children by pretending their signs of captivity are part of a game being played with guards.In the clip, Coleman said she and her family had been living a “Kafkaesque nightmare” since 2012. The Boyles had said their daughter-in-law could not have used a more accurate term.In commenting on news of the family’s release from captivity, U.S. Premier Donald Trump praised Pakistan for its willingness to “do more to provide security in the region.” Baldor reported from Tampa and Colvin from Washington. Associated Press writer Jon Gambrell in Dubai contributed to this report.