Fix tmp file cleanup