Why were Afghanis who wanted to leave still there at the end?

Early 1970’s. Half a century ago.

Varies by country, of course, but at a minimum months and quite plausibly years, especially over the past year and a half due to covid travel restrictions.

OK - so they had 50 years to complete the paperwork.

Many of these people weren’t just refugees; they had worked for and with the US military as translators and, as I understand, had been promised that they’d get visas to come to the US.

Paperwork that isn’t accepted doesn’t get you anywhere.

And my country, Canada, didn’t do a stand-up job at this either; apparently our fed gov’t, from an administrative pov, basically dealt with this as though our interpreters and other Afghan workers and supporters had the same material goods as someone in Scarborough or Barrhaven (two typical Canadian suburbs), forcing them to deal with complex online application forms and paperwork that would be a frustrating challenge to any westerner.

So rather than our government doing sufficient work (which could have been ongoing for years, but wasn’t), it’s primarily Canadian veterans and private citizens organizing and funding safe-houses and various exit methodologies.

And IMHO, the US withdrawal (in addition to our own mismanagement) was a colossal cock-up.