Cleanup pipes properly. Fixes #182