Corrected event name from 'error' to 'end', as 'error' is not emitted on pipelines