diff --git a/src/wrap.c b/src/wrap.c
index ee8dac762c7668b1037ad1fecb0de1bfcd204e8a..6e01655d2a51d2910f7fb289a18e4c731e1b2b7d 100644
--- a/src/wrap.c
+++ b/src/wrap.c
@@ -2153,6 +2153,17 @@ main (int argc,
 
   flatpak_bwrap_finish (bwrap);
 
+  /* Clean up temporary directory before running our long-running process */
+  if (tmpdir != NULL &&
+      !glnx_shutil_rm_rf_at (-1, tmpdir, NULL, error))
+    {
+      g_warning ("Unable to delete temporary directory: %s",
+                 local_error->message);
+      g_clear_error (&local_error);
+    }
+
+  g_clear_pointer (&tmpdir, g_free);
+
   /* flatpak_bwrap_finish did this */
   g_assert (g_ptr_array_index (bwrap->argv, bwrap->argv->len - 1) == NULL);