If your VM has a virtual CD/DVD drive, and it's set to Connect at power on, and configured to Use a physical drive, then the guest OS will have control of the CD/DVD drive "lock", which may prevent the eject button on the front of the drive from operating. The guest OS chooses when to use the lock, and it usually does so to prevent the disc from being removed without its knowledge. The tray should be unlocked again when the guest OS shuts down.
The easiest way to prevent this would be to go into VM> Settings> Hardware tab, choose CD/DVD, and unselect Connect at power on. The VM should no longer be able to access the drive and lock the tray.
Cheers,
--
Darius