Command Line (CLI) Command for disconnecting wifi from current network
Use networksetup.
There are several ways to disconnect from a Wi-Fi network via Terminal:

Disable the Wi-Fi service.  This will require root privileges.  The radio will remain on, but it won't connect to anything.
$ sudo networksetup -setnetworkserviceenabled Wi-Fi off

Turn off the airport power (this is like clicking the (GUI) Wi-Fi icon and selecting &quot;turn off Wi-Fi&quot;.  You don't need sudo and you should know which interface (en0, en1, etc.) is your Airport adapter.  If you don't try the service and macOS will attempt to guess which one it is.
$ networksetup -setairportpower Wi-Fi off


In the specific case where you don't want auto join, just set the network to not auto join and then toggle the network status using networksetup.
If you just want to disconnect from a WiFi network, disable the adapter:
$ sudo networksetup -setnetworkserviceenabled Wi-Fi off &amp;&amp; sleep 15 &amp;&amp; sudo networksetup -setnetworkserviceenabled Wi-Fi on
(You can issue the command without sudo but you will get a popup prompting you for a password for each networksetup invocation)