close pipes

In production when using this in an app that stays online forever, files were being opened by pipe and never closed and increasing overtime, when the app stopped they were closed, but this closes the pipes after execution of the script.