When you attach an external drive or other secondary drive to a Mac, the volume on it will mount and become available in the Finder and the Finder sidebar for your various uses. To eject the drive, you simply need to click the eject button next to the drive's name in the sidebar, or select the drive and press Command-E, choosing the option to do so from the contextual menu, or even drag it to the trash.
These actions can be performed on one or more selected volumes; once it's ejected, you can safely remove the drive from the system.
While this action is usually straightforward, it may be a little more cumbersome if you have one or more drives with multiple partitions on them. In these instances, if you eject one, the system will prompt you for an action to take regarding all volumes on the drive; you can eject all volumes on the drive or just the one you have selected.
This feature helps prevents you from removing one volume and then disconnecting the drive while another volume is still in use.
It's a nice reminder, but if you prefer to avoid this popup whenever you eject a drive, you can include a couple of modifier keys when ejecting volumes to immediately perform these tasks. The first modifier is the Option key, which when held will eject all volumes on the associated disk. The second is to hold the Control key, which will leave the other volumes mounted and only eject the targeted volume.
The mode by which you eject the volumes in this manner does not matter, so you can hold these keys while clicking the volume's eject buttons, or you can include it in the ejection hot-key sequence, so selecting the drive and pressing Option-Command-E will eject all volumes, and Control-Command-E will eject only the selected volumes.
In addition, you can use it when dragging volumes to the trash.
The origin of trashing a volume to eject it
Some people might find it odd that one option for ejecting volumes on the Mac is to drag them to the trash. It comes from the initial versions of the Mac OS where the system would create a cache to represent and provide access to a mounted disk. Unmounting the drive alone would leave behind this cache, which then had to be dragged to the trash. Apple combined these actions so that dragging the disk to the trash both removed the cache and unmounted the drive, and this action stayed with the OS.