Make sure you change your password. That's a good idea in general when trying to avoid a compromised account:
Click on this link "If you think your Apple ID has been compromised" --> If you think your Apple ID has been compromised - Apple Support
For iOS 15 or earlier, if you want to see if anyone else has access to your device or accounts, click here --> See who has access to your iPhone or iPad - Apple Support
For iOS 16 or later see how Safety Check on iPhone works to keep you safe. How Safety Check on iPhone works to keep you safe - Apple Support
Related materials:
Personal Safety User Guide
Personal Safety User Guide - Apple Support
> open the Table of Contents
A document with general information about security and your Apple ID --> Security and your Apple ID - Apple Support
Note that Apple has various sharing features. These are places where you are voluntarily opening a sharing door to various items. The person cannot reach in and grab them, and they can't delete items, only copy them.
How to use Shared Albums in Photos on your iPhone, iPad, and Mac - Apple Support
Share files and folders in iCloud Drive on iCloud.com - Apple Support
Of course if you were part of Family Sharing you need to either remove your ex from the group of leave it.
Leave Family Sharing - Apple Support