Hi ewq,
To remove the custom domain, you need to free the domain from your tenant. You must first remove the domain name from all users, groups, or Office 365 accounts associated with the domain.
1. Change the suffix of your users to the primary domain (domain.onmicrosoft.com).
onlinehelp.microsoft.com/.../ff637577.aspx
You can change the domain suffix on Details tab.
2. Please also edit the domain suffix of distribution group. Click Details button of the group. Locate E-mail address field and change the domain suffix.
3. Delete all the proxy addresses connected with this domain.
help.outlook.com/.../cc511403.aspx
4. Please also check if this domain is used by SharePoint online.
Moreover, you can refer to this KB to troubleshoot this issue:
support.microsoft.com/.../2284755
After that, you can wait some time for the provision and try to remove the domain again.
Thanks,
Young Yang