on-finished reliably executes a callback function when a stream closes, finishes, or errors. It provides a consistent, cross-platform mechanism for detecting stream completion, regardless of the underlying event. This utility is crucial for resource cleanup, logging, or performing actions after a stream's data transfer is complete. By handling various stream termination scenarios, on-finished promotes robust and predictable application behavior, ensuring your code gracefully handles stream events.