ensure proper cleanup