remove tmp files and also exit with rc 1 in case of err.