It doesn't happen a lot, but sometimes a CD or DVD gets stuck in my mac and it won't eject using the keyboard or dragging it into the trashcan.
When this happens I just open the terminal and type the following command, which usually overrides whatever is blocking the disc to eject:
drutil tray eject
Although I'm not sure when I'd ever use it there's also a close command.
drutil tray close