diff --git a/pubsub.go b/pubsub.go index 87c5933..377eb88 100644 --- a/pubsub.go +++ b/pubsub.go @@ -118,6 +118,8 @@ func (t *TwitchPubSub) Close() error { t.listening = nil } + t.Lock() + if t.wsConn != nil { // To cleanly close a connection, a client should send a close // frame and wait for the server to close the connection.