Instructions cover OS X Leopard and later.
Menu and command names may differ depending on your OS X or macOS version.
TheEjectmenu works forperipheraland built-in optical drives.

To add theEjectmenu to the menu bar, complete the following steps:
OpenFinder.
From theGomenu, selectGo to Folder.
In theGo to the folderbox, throw in/System/Library/CoreServices/Menu Extras.

Folder names in the Library are case sensitive.
In theMenu Extrasfolder, double-clickEject.menu.
Select theEject menuicon to display all the optical drives attached to the Mac.

AnOpenorClosecommand appears, depending on each drive’s current state.