Only a good idea if:
-you’d be willing to take a life to save your own
-you’re willing to get training. Buying a gun makes you able to shoot to the same extent buying a piano makes you able to play the minute waltz.
Otherwise, consider other means.
A gun you cannot access is the most useless thing in the world. Think about getting a carrying permit if it’s legal in your jurisdiction. Otherwise, if you can, carry a pepper spray that is 5% or more OC. Buy two, and practice with one can.
This person does not sound psychologically / psychiatrically well. Stop being nice. Stop being polite. Do not initiate contact. The next time he initiates contact, tell him loudly and forcefully to stop, that you never want him to contact you again. Then never talk to him again. Don’t answer when he calls, turn around and walk away if you see him.
You gave the guy mixed messages, so maybe it is time you stepped up and simply had a real heart-to-heart talk with him.
Next time you see him out, buy him a beer and then let him know it isn’t ever going to happen again, but you can still be civil to him.
I have been with lots of guys once, twice or more times and then realized it wasn’t going to work out over the long run. Some of them are still very good friends decades later.
Once is not stalking. Once is some guy trying to get lucky because past experience says it might happen. To call it stalking is a bit dramatic. If you tell him you are not interested and he continues, then its stalking.