I'd have handled it by getting noticeably angry with the guy in an attempt to intimidate the perp (that's the appropriate name), used my phone to snap a pic of him, and called the police to report attempted B&E, since what the guy did falls under B&E laws in most jurisdictions.
I get that OP may have reasons to not do those things (eg. cops wouldn't respond), but he didn't specify any. It looks to me like that perp left without having a reason to not try again later on in the same hour, or maybe the next 2 minutes in the same building.
Of course a True leftie would have given him $50 and a pat on the back for having endured a hard-scrabble life wot led him to these terrible life circumstances where B&E-burglary is the only choice left to him.