Gillian: what a disturbing story. I would have advised you to call the police and report a stalker was harassing you. After that, I would have advised obtaining a court-filed restraining order. Then if the stalker continued he would be subjected to arrest for violating the restraining order.
More specifically, this is a problem which women need to be mindful of: being friendly or even overly polite can send the wrong message to some desperate men. These losers think that any acknowledgement of them by a woman means interest in them — even just being courteous like saying thank you for holding open a door or engaging in seemingly harmless banter about the weather while taking an elevator. No, not all men are desperate stalkers, but some are. That’s why women should keep their guard up and politely disengage when proactively engaged: sorry, I don’t talk to strangers, or FYI I have a jealous husband with a loose trigger finger. Let them know immediately there’s no interest whatsoever, otherwise deranged idiots might assume the opposite and recklessly pursue innocent women. Glad to know it turned out okay for you.