Or is there a simple function to use, such as delete_user() ?
In the latest versions of Moodle you can configure Moodle to raise a GDPR delete request when a user is deleted. User who have previously been deleted and who do not have a GDPR delete request can also be created en bulk via a new scheduled task that you can run.
You can also bulk approve these requests.
I would not recommend using the utilities. They are very basic and do not respect the 'Protected' flag on the various contexts. The actual APIs do respect this flag.