Revert "Revert "Delete temp files with ~ in the end.""

This reverts commit 58e65a6766326d151c20be4f325837c6891afd11.