some exception handling for stream termination.