UPDATE: It turns out that there is a way of doing this not only in macOS, but in all *NIX systems thanks to the mvp/uhubctl repository over on GitHub. The program is called uhubctl, and allows you to toggle and cycle power on individual ports for supported USB hubs.
As the description would imply, you'll need to know which USB port the device in question is connected to (or cycle the entire hub if you're confident it won't cause and issues with other peripherals), and I still recommend using
diskutil eject diskX (or
sudo umount /dev/sdX for Linux and
umount diskX for BSD) before power cycling the port to ensure that the device unmounts cleanly.
uhubctl home page is here (you can get source code using
git clone https://github.com/mvp/uhubctl).
You'll need to compile it from source one way or another, either with
make or via
brew. Whichever you choose, you're going to need
libusb version 1.0.22 installed. If you have brew installed, you can do it in one swoop by:
brew install libusb
brew tap mvp/uhubctl https://github.com/mvp/uhubctl
brew install --HEAD uhubctl
Tested and can confirm working with both Apple and 3rd party USB hubs on macOS 10.13.1.
P.S. @aeroxy I concede that all along you were correct, and I was wrong.
If you want to unmount it and have it's UDI (Unix Disk Identifier, i.e.
disk1s3 for the 3rd partition on your second drive) you can run
diskutil unmount diskXsX from the terminal, and remount it by using the same command, replacing unmount with mount.
If you are using
Android Debug Bridge to connect it you can open a terminal, go to whatever folder its installed to, and run
./adb stop to shut down the local Android USB server, then
./adb start to reconnect when you need to.
You could also use Disk Utility to unmount the device.
Finally, if you want to eject it to simulate unplugging it completely without physically unplugging it run
diskutil eject diskXsX from the command line, or right-click the phone in Disk Utility and click the "Eject" button.
EDIT: If you are not using ADB or a similar program like Android File Transfer (AFT) then you will not be able to disconnect the device, because it never connected in the first place. In order for an android device to connect to a Unix system (and by extension macOS) you need to fulfill two conditions: 1.) The device must have developer mode enabled, and USB debugging turned on, or your device will auto-deny any requests from another computer to connect through USB. 2.) You must have a program like ADB or AFT installed, these programs run a local Android MTP server and are required to send the connection request to and read the filesystem of the Android device.
Developer mode can be enabled by going to
Settings>About Device> and tapping on
Build Number 7 times, USB Debugging is in the developer options menu that it now at the bottom of your settings page.
The official AFT app for macOS can be found here: [link] (https://www.android.com/filetransfer/) and the command line version of ADB can be found here: [link] (https://developer.android.com/studio/releases/platform-tools.html#download)
Once both prerequisites have been met you should be able to disconnect the device without unplugging it by stopping the ADB server or by unmounting/ejecting it as one would with any other external filesystem.