catch possible err while closing pipes
fix debug output