Cleaning up a resource on failure.