Ensure proper cleanup