Cleanup Code - Fix problem writing to closed STDIN/ERR ...