It takes time and patience on your part, someone who is used to being in control has now lost or is losing that control.
I had very similar from my ex, he would climb into my garden and try to enter the house, everywhere I went he was there.
Start recording everything he is doing. Dates/times places he shows up uninvited etc and be firm with the boundaries.
In my experience putting the boundaries in made him worse and I couldn’t believe how he acted, so also be prepared to enforce boundaries by alerting the police.