Best to use some backend workflows for this…
The simple way is to just delete the User once the user decides to close their account. Then they wont be able to log in. Job done.
But, depending on your use case, you may not want to actually delete the user, but rather just ‘de-activate’ them so they can no longer use your app (so you can keep their user data as a record, or reactivate their account at a later date should they wish to do so).
In that case just have a yes/no field on the User datatype to define whether a user is active or not, and use conditionals in your app so only active users can login and access features. (you’ll need to be careful with things like GDPR and data-protection here - i.e. depending on your terms of service and privacy/data protection policies etc. if a user requests to close their account they may expect that their data is also deleted - so make sure you have a clear policy set out to avoid any legal issues).
If the user has created data and/or uploaded files then again you may, or may not, want to remove all connected data and files for the user from your database.
In that case you’ll need to do all of that first, before deleting the user. It will depend how you’ve got your database set up as to exactly how to do it, but you’ll need to run some backend workflows, either recursively, or using the ‘Schedule Backend Workflow on a list of things’ function, to delete all the associated data for the user, before deleting the User data entry itself.