end the stream once the form has closed