Fix deadlock in disconnect()

This fixes a deadlock in connect() if already disconnected.