fix cleanup flow for memfree devices