Added try/catch block to avoid errors when stderr is closed.