Occasionally when I eject a CD or DVD using the normal Mac OS X methods (either pressing the "eject" button on the keyboard or dragging a volume to the trash", the volume disappears, but the disc doesn't come out. Every time this happens, I browse the usual troubleshooting sources (eg., macosxhints.com), and find the unhelpful procedure using the Terminal "hdiutil" utility. This only works if the volume is mounted.
Today, I discovered a Terminal utility that helped. It is called drutil. Between these two commands, I've been able to eject a stubborn DVD without resorting to the Apple-recommended procedure of
Launch a Terminal window and at the command prompt, type:
$ drutil status
This should display information about your optical drive and the media loaded, even if the df command (as recommended elsewhere) doesn't. Now look for the line which contains the "Type:" and "Name:" info. Use the information following "Name:" in the following command:
$ hdiutil eject /dev/disk2
Voila! Well, it worked for me anyway. As always, YMMV.