I assume your deployed strategy is running while you redeploy a new strategy, and this is leaving the websocket in previous deployment still alive, causing a leak.
One simple way is to handle keyboard interrupt.
https://stackoverflow.com/questions/4205317/capture-keyboardinterrupt-in-python-without-try-except
Make sure you do the websocket connection inside a new thread. Use the main thread for the signal handler as shown in above url. Perform cleanup (unsubscribe+disconnect) in the signal handler function.