docs: def finish(self):
          """Finishes this response, ending the HTTP request."""
          if self._finished:
              raise RuntimeError("finish() called twice.  May be caused "
                                 "by using async operations without the "
                                 "@asynchronous decorator.")
          if not hasattr(self, '_stream_queue') or not self._stream_queue:
              raise RuntimeError("`_stream_queue` was not assigned, you should"
                                 "call `write_stream_queue` to set.")
  
          # === Replace `if not self._headers_written` === #
          self.set_status(200)
          self.set_header("Content-Type", "text/event-stream")
          self.set_header("Cache-Control", "no-cache")
          self.set_header("Access-Control-Allow-Origin", "*")
          # ============================================== #
  
          self.request.connection.set_close_callback(None)
  
          # === Add before self.flush === #
          # Reset buffer
          self._write_buffer = []
          self._headers_written = False
          # ============================= #
  
          self.flush(include_footers=True)
  
          # === Add after self.flush === #
          self._write_buffer = self._stream_queue
          self.request.connection._write_buffer = self._stream_queue
          # ============================ #
  
          self.request.finish()
          self._log()
          self._finished = True
          self.on_finish()
          # Break up a reference cycle between this handler and the
          # _ui_module closures to allow for faster GC on CPython.
          self.ui = None