You have to create an independent process whose context doesn't depend on the context of the database. While that file is open, it is locked against deletion. Further, if you implemented Access security, you have to overcome your own protection scheme because this process has to run as the data owner or as the administrator, who can take over ownership of the data.
The trick is of course to have the process do what you want while assuring that it does NOT take out the rest of your operating system. Further, if you have any anti-virus code running that has heuristics or "suspicious behavior detection" features, it might stop you.
On top of that, even if this is shared code, you will have the issue of assuring that no one else is in the code when this "remover" is trying to run. I have to say, this is not a trivial thing to assure. Search this forum for the topic of "Kicking Out" or "Ejecting" unwanted users at a selected maintenance time. I won't try to reinvent that wheel.
I might take the approach of writing a "poison pill' routine that runs perhaps via a macro.
Have the macro do a RUNCODE on something in a module that contains nothing else. Then in that module, have a series of loops that visits every collection: Tabledefs, QueryDefs, Documents, Modules, Forms, and Reports.
Do this more or less as:
Take whatever steps you find suitable from the search for assuring that no one else is in the database but you.
For every open form, close the form.
For every open report, close the report.
For every document (which includes closed forms and reports), delete the document.
For every querydef, delete the querydef.
For every table that isn't a system table, delete the table.
Now have the code do an automatic Compact and Repair on Exit. Then QUIT the application.
While it might not be totally gone, it will never run again. There is, however, this additional catch. If the application exists on backup tapes and is restored, you cannot stop it from running again unless it has a way to know that it shouldn't be running - like a registry entry with an obscure name, meaning, or format. Look up the xxxxSettings functions, which allow you to interact with the registry. The Help files will tell you about them.
I'm sure I've forgotten something, but maybe this little voyage through the mine field of automated product de-installation will help you realize just what you asked to do.