How do I stop remote access?
It all depends on how far your ex went with installing unwanted software on your device.
In most cases a factory restore would remove unwanted software.
Just make sure to copy your important data (photos/messages/etc.) somewhere else before doing it.