add pipe close logic