Add closePipe function
Fix closing of pipes