fix async-handling for stream ends