Have you asked support if they have a guide for removing all Cloud specific things? They used to have that atleast.
Here's what I would do (assuming v9+):
Take a backup of the database and site to work on.
Install usync and do a full export.
Remove all references to umbraco cloud/ deploy packages in the csproj.
Remove all the cloud specific files, like the dockerignore, .umbraco file, umbraco-cloud.json, etc.
Spin up a new database and connect from the site and install umbraco anew
Import from usync
At that point it should be clear of all Umbraco Cloud specific things as far as I know and be a "fresh" site with all content and schema imported