If you would prefer to be left alone, just say that, but in a nice way, like: "Thanks for stopping by but I'm sort of busy and would like to be alone." Say that enough times, over enough days, and he will stop coming over to talk.
Or if that doesn't work, just say "I just had a bad breakup and don't want any relationship right now."
I have a long time interest in psychology, specializing in relationship dynamics for 30 years.
(Please note, we give the best advice we can based on the information given in a post. For better advice, please include the age of all romantic partners.)