On the one hand, I have several factories where each factory controls a websocket.
On the other hand, One of those factories should be started when client is logged, so:
You cannot destroy factories, they are singletons and they are created only once when they are first required by a module.
You can add to your factory two methods:
close() which will create and close socket.
When user logins you call
setup(), when logging out -