How to eject device

You can eject a volume using AppleScript as described here: