Free memory in case of failure