Hi,
Before demote the last domain controller and remove the domain, you have to disable the synchronization between Azure AD and your on-premise domain by running the following command : Set-MsolDirSyncEnabled -EnableDirsync $False
I invite you to read the following links to learn more about the command above:
Set-MsolDirSyncEnabled Turn off directory synchronization for Microsoft 365
Once the Directory synchronization is off , check if all synchronized accounts in Azure AD can be managed through Azure portal. If it's Okay , you can perform the demote of the last domain controller.
Please don't forget to mark helpful reply as answer