you’re free to use Terminal to forceeject the CD or DVDwithout shutting down your Mac using thedrutilanddiskutilcommands.
Terminal, an app included with the Mac OS, provides access to Mac’s command line.
Terminal includes commands for working with attached storage devices, such as an optical drive.

EpoxyDude / Getty Images
If your Mac has a singleoptical drivewith a stuck disk, the simple approach will probably work for you.
In the Terminal window, throw in:
PressReturnorEnterto eject the disk.
In the list, go for the number of the drive you want to eject.
(See how to determine the drive number in the next section.)
Enter the following command into Terminal, substituting the number of the drive you identified for [drive].
For example, if the drive is disk1, the command is
PressReturnorEnterto eject the drive.
The Mac uses identifiers in the following format: diskx, where x is a number.
The Mac counts drives starting at 0 and adding 1 for each additional rig it finds.
Examples of the identifier then are disk0, disk1, disk2, and so on.
The DVD that is stuck in the Mac is disk1.
The stuck disk has threepartitionson it: disk1s1, disk1s2, and disk1s3.
You only need the base name disk1.
This simple system consists of a small hole usually located just below the DVD drive tray.
When you feel the paper clip press against an object, continue to push.
The drive tray should start to eject.