More stable pipe handling when exiting a spawn