<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def end_stream(self, stream_id):
 """ Close the given stream locally. This may block until the underlying transport becomes writable, or other coroutines release the wlock on this stream. :param stream_id: Which stream to close. """

        with (yield from self._get_stream(stream_id).wlock):
            yield from self._resumed.wait()
            self._conn.end_stream(stream_id)
            self._flush()