# How to close a streaming connection?

**URL:** <https://forum.alpaca.markets/t/how-to-close-a-streaming-connection/7526>\
**Category:** Getting Started with Alpaca\
**Created:** [November 23, 2021, 10:03pm UTC](https://forum.alpaca.markets/t/how-to-close-a-streaming-connection/7526 "2021-11-23T22:03:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matthew](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@Matthew](https://forum.alpaca.markets/u/Matthew)\
**Post date:** [November 23, 2021, 10:03pm UTC](https://forum.alpaca.markets/t/how-to-close-a-streaming-connection/7526/1 "2021-11-23T22:03:26Z")

</div>

I can’t figure out how to properly close a streaming connection…

I do see [this example that shows](https://github.com/alpacahq/alpaca-trade-api-python/blob/master/examples/websockets/streamconn_on_and_off.py) how to pause the websocket, but that doesn’t actually close the connection, I’m still authenticated.

```auto
loop.run_until_complete(self.conn.stop_ws())

```

My problem is I’m using TKinter for UI in Python, but when I click the X icon to close the window and close my program, it doesn’t actually close because it’s still connected to the stream.

I’m sure this is a noob question, but I’ve dug through the API and I can’t figure it out.

Idk if this is an asyncio issue, or a threading issue, a tkinter issue, or a Alpaca API issue. I’m a Python novice.
