A man who barricaded himself inside his Fairfax County home with his two children for more than 17 hours was taken into custody Monday afternoon, police said. The children, ages 4 and 8, are safe.

Police said the children exited the home in the Fort Hunt area shortly after 1 p.m., but the unidentified man, who appeared to be suffering from a mental health crisis, remained uncooperative and did not follow officers’ commands.

The man repeatedly walked in and out of the home and was eventually subdued with a stun gun, police said. As part of routine procedure, the man was transported to a hospital for treatment.

Police blocked off areas around Culpeper and Londonderry roads Monday as they tried to safely coax the man out, said Officer Tawny Wright, a spokeswoman for the department.

Officers responded to the man’s home around 8 p.m. Sunday after a friend who was talking on the phone with him became concerned that he was experiencing a crisis and called police, Wright said.

Officers tried to take the man into custody for emergency psychiatric services, but the man refused to go with police and barricaded himself in the home with his children, Wright said. The man did not threaten his children, police said.

It is unclear whether the man had a weapon, but negotiators spoke on the phone with him periodically since Sunday night, Wright said.

With children involved, “it elevates the concern for us and causes us to approach things more delicately,” Wright said.