Merge "Properly handle failures during resource cleanup"