Ensure temp variables are freed before a return.