The command to eject a disc from the command line is:
You can optionally also umount it first:
And then eject it manually, the thing is it has to be umounted before you can 'unlock' the drawer. eject does that all in full swoop, but that's the only thing I know of that does.
You have to make sure that nothing is accessing the drive at the time, and that no one in is the mounted directory. You can usually do that pretty easy on a single user system, but if you've got multiple people, drop back to init 1 and go from there:
And then run:
As root of course.