Welcome to PF 🐩
Has he been going out alone, without supervision? If so, yes to the potential for danger and to the lost opportunity for reinforcing the behavior wanted.
Are you noting that this is late at night, sleeping time only or anytime after dark?
If he's been alone outside, it's quite possible that something scared him. My boy, Remo, went through a phase where he just would not go in the backyard at night. I'm always either out with him or watching from the door. I never saw what might have changed his behavior but finally got the bright idea to leash him and go to the front where we start our walks and there are trees, trees that the p-mail is on. That worked! It took a few weeks, iirc, but I kept trying the backyard with him and eventually it became acceptable again.
Also, what form does his anxiety take and what are the triggers?