check if error stream is not null and clean up