diff --git a/create-iso.sh b/create-iso.sh
index abb119ae1aa253d7c42bf03376b18e4a71890dde..384817f19e2e0710121babb02a2742f4eba06c25 100755
--- a/create-iso.sh
+++ b/create-iso.sh
@@ -142,8 +142,9 @@ replaceIso()
         if [ "$ack" == "y" ]; then
             log "Cleaning temporary directory ..."
 
-            rm -rf "$TMP"/* "$CHROOTDIR" "$CDDIR" "$SQUASHIMAGE" || return 6
-            #$0 --clean --dist $1 || exit 6
+            if ! cleanFiles; then
+                return 6
+            fi
         else
             log "Extraction canceled!"
             return 1
@@ -153,6 +154,13 @@ replaceIso()
     return 0
 }
 
+# Remove files used on the generation process and umount files
+cleanFiles()
+{
+    checkMountedFS
+    rm -rf "$TMP"/* "$CHROOTDIR" "$CDDIR" "$SQUASHIMAGE" || return 6
+}
+
 log()
 {
     if "$LOGINFO" && [ "$1" ]; then
@@ -253,7 +261,6 @@ checkOutput "$OUTPUT" || exit 8
 
 #------------------------------------------------------------------------------
 # Init routines
-
 if $iso; then
     if ! regenerateManifest | log; then
         log "Error to regenarate manifest file"
@@ -272,10 +279,6 @@ elif $edit; then
         log "Error to edit Squash image"
         exit 2
     fi
-elif $clean; then
-    log "Cleaning temporary directory ..."
-
-    rm -rf "$TMP"/* "$CHROOTDIR" "$CDDIR" "$SQUASHIMAGE" || exit 6
 elif $all; then
     replaceIso $distName || exit 6
 
@@ -300,7 +303,9 @@ elif $all; then
         exit 5
     fi
 fi
-
-#/root/teste_ram/rsync.sh
+if $clean; then
+    log "Cleaning temporary directory ..."
+    cleanFiles || exit $?
+fi
 
 exit 0