Cleanup temporary files during directory removal (fixes #919)