The most common solution is pressing the eject key on the keyboard.
If that fails for some reason (in my case the key was not working properly) you could always drag the DVD icon to the trash or right-click (ctrl-click) it and click “eject” – as long as there is a CD or DVD in the drive. But what if it’s empty and you want to insert a disc?
Open a terminal window (Terminal.app) and type drutil tray eject
. To close type drutil tray close
accordingly.