stream_terminate_connection: Prevent use-after-free