diff --git a/nuxeo-core/nuxeo-core-convert-plugins/src/main/java/org/nuxeo/ecm/platform/convert/plugins/CommandLineConverter.java b/nuxeo-core/nuxeo-core-convert-plugins/src/main/java/org/nuxeo/ecm/platform/convert/plugins/CommandLineConverter.java
index 21d5bba47e5..34f0c48897f 100644
--- a/nuxeo-core/nuxeo-core-convert-plugins/src/main/java/org/nuxeo/ecm/platform/convert/plugins/CommandLineConverter.java
+++ b/nuxeo-core/nuxeo-core-convert-plugins/src/main/java/org/nuxeo/ecm/platform/convert/plugins/CommandLineConverter.java
@@ -95,6 +95,7 @@ public class CommandLineConverter extends CommandLineBasedConverter {
             String prefix = String.format("clc-%s-", FileUtils.getSafeFilename(getCommandName(blobHolder, parameters)));
             Path outDirPath = tmpDirPath != null ? Files.createTempDirectory(tmpDirPath, prefix)
                     : Framework.createTempDirectory(prefix);
+            Framework.trackFile(outDirPath.toFile(), outDirPath);
 
             Map<String, String> cmdStringParams = new HashMap<>();
             cmdStringParams.put(OUT_DIR_PATH_KEY, outDirPath.toString());
diff --git a/nuxeo-core/nuxeo-core-event/src/main/java/org/nuxeo/ecm/core/work/WorkComputation.java b/nuxeo-core/nuxeo-core-event/src/main/java/org/nuxeo/ecm/core/work/WorkComputation.java
index b31a221d0e0..5c377b6ccd7 100644
--- a/nuxeo-core/nuxeo-core-event/src/main/java/org/nuxeo/ecm/core/work/WorkComputation.java
+++ b/nuxeo-core/nuxeo-core-event/src/main/java/org/nuxeo/ecm/core/work/WorkComputation.java
@@ -134,6 +134,7 @@ public class WorkComputation extends AbstractComputation {
         } finally {
             workTimer.update(work.getCompletionTime() - work.getStartTime(), TimeUnit.MILLISECONDS);
             work = null;
+            Framework.cleanTempFile();
         }
     }
 
diff --git a/nuxeo-core/nuxeo-core-event/src/main/java/org/nuxeo/ecm/core/work/WorkHolder.java b/nuxeo-core/nuxeo-core-event/src/main/java/org/nuxeo/ecm/core/work/WorkHolder.java
index bd786973f6e..3345cb068f2 100644
--- a/nuxeo-core/nuxeo-core-event/src/main/java/org/nuxeo/ecm/core/work/WorkHolder.java
+++ b/nuxeo-core/nuxeo-core-event/src/main/java/org/nuxeo/ecm/core/work/WorkHolder.java
@@ -21,6 +21,7 @@ package org.nuxeo.ecm.core.work;
 import java.util.concurrent.ThreadPoolExecutor;
 
 import org.nuxeo.ecm.core.work.api.Work;
+import org.nuxeo.runtime.api.Framework;
 import org.nuxeo.runtime.trackers.concurrent.ThreadEvent;
 
 /**
@@ -58,6 +59,7 @@ public class WorkHolder implements Runnable {
         } finally {
             currentThread.setName(name);
             ThreadEvent.onLeave(this).send();
+            Framework.cleanTempFile();
         }
     }
 
diff --git a/nuxeo-runtime/nuxeo-runtime/src/main/java/org/nuxeo/runtime/api/Framework.java b/nuxeo-runtime/nuxeo-runtime/src/main/java/org/nuxeo/runtime/api/Framework.java
index 78e144f070d..9746d07a3a9 100644
--- a/nuxeo-runtime/nuxeo-runtime/src/main/java/org/nuxeo/runtime/api/Framework.java
+++ b/nuxeo-runtime/nuxeo-runtime/src/main/java/org/nuxeo/runtime/api/Framework.java
@@ -26,7 +26,10 @@ import java.net.URL;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.attribute.FileAttribute;
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.Properties;
 import java.util.function.Supplier;
 
@@ -35,6 +38,7 @@ import javax.security.auth.login.LoginContext;
 import javax.security.auth.login.LoginException;
 
 import org.apache.commons.io.FileDeleteStrategy;
+import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -70,6 +74,8 @@ public final class Framework {
 
     private static Boolean testModeSet;
 
+    public static Map<String, List<File>> collectedFilesByThread;
+
     /**
      * Global dev property
      *
@@ -131,6 +137,7 @@ public final class Framework {
         runtime = runtimeService;
         reloadResourceLoader();
         runtime.start();
+        collectedFilesByThread = new HashMap<String, List<File>>();
     }
 
     public static void reloadResourceLoader() {
@@ -527,6 +534,33 @@ public final class Framework {
      */
     public static void trackFile(File aFile, Object aMarker) {
         FileEvent.onFile(Framework.class, aFile, aMarker).send();
+        String threadName = Long.toString(Thread.currentThread().getId());
+        if (!collectedFilesByThread.containsKey(threadName)) {
+            collectedFilesByThread.put(threadName, new ArrayList<File>());
+        }
+        collectedFilesByThread.get(threadName).add(aFile);
+    }
+    
+    public static void cleanTempFile() {
+        String threadName = Long.toString(Thread.currentThread().getId());
+        if (collectedFilesByThread.get(threadName) == null) {
+            return;
+        }
+        for (File f : collectedFilesByThread.get(threadName)) {
+            if (f.exists()) {
+                log.info("Deleting file " + f.getAbsolutePath());
+                if (f.isDirectory()) {
+                    try {
+                        FileUtils.deleteDirectory(f);
+                    } catch (IOException e) {
+                        log.error(e);
+                    }
+                } else {
+                    f.delete();
+                }
+            }
+        }
+        collectedFilesByThread.remove(threadName);
     }
 
     /**
diff --git a/nuxeo-services/nuxeo-platform-web-common/src/main/java/org/nuxeo/ecm/platform/web/common/encoding/NuxeoEncodingFilter.java b/nuxeo-services/nuxeo-platform-web-common/src/main/java/org/nuxeo/ecm/platform/web/common/encoding/NuxeoEncodingFilter.java
index 731e40c7913..4c2106f0ce5 100644
--- a/nuxeo-services/nuxeo-platform-web-common/src/main/java/org/nuxeo/ecm/platform/web/common/encoding/NuxeoEncodingFilter.java
+++ b/nuxeo-services/nuxeo-platform-web-common/src/main/java/org/nuxeo/ecm/platform/web/common/encoding/NuxeoEncodingFilter.java
@@ -30,6 +30,7 @@ import javax.servlet.ServletResponse;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.nuxeo.runtime.api.Framework;
 
 /**
  * Filter that sets encoding to UTF-8, before any other filter tries to parse the request. Also set the X-UA-Compatible
@@ -62,6 +63,8 @@ public class NuxeoEncodingFilter implements Filter {
         }
 
         chain.doFilter(request, response);
+        Framework.cleanTempFile();
+
     }
 
     @Override
