Hi Eugen,
perhaps setting the deleteAfterDownload flag on files can help. See the mendix guideline - https://docs.mendix.com/howto40/generate-documents-using-document-templates
As far as I know, mendix will delete files with this flag either after they are donwloaded OR when the user logs out.
I think its worth a try, if you are not using this already.
-Andrej