Demotion and leaving as a member server is fine to do. In case the demotion does not go cleanly, you can finish with metadata clean up.
https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/deploy/ad-ds-metadata-cleanup
https://techcommunity.microsoft.com/t5/itops-talk-blog/step-by-step-manually-removing-a-domain-controller-server/ba-p/280564
--please don't forget to Accept as answer if the reply is helpful--