Resource cleanup in pipes