There is no practical way to detect when the user is done using a file that your app shared.
One way to deal with this situation is to delete any files that were shared *the next time your app is run*.
For example, let say your app shares the file "main.txt" to another app, which the user then uses the other app to work with the shared file. Now, when the user runs your app again, it is usually safe to assume that the user no longer is viewing the previous "main.txt" file.
So, in the startup code of your app, you can delete the previously shared file "main.txt" (or if the shared files always end in .txt, you can do a delete of *.txt so you wont have to keep track of the file name of each file your app shared).
This way all previously shared files will be deleted each time your app is run, so you phone memory will not keep filling up.