Clear pipe before closing it