To open a CD or DVD drive while the computer is turned off, use an extended part of a paperclip, and insert it in the small hole on the drive intended for manual ejection. Once the gear inside the drive moves, open the tray gently with your fingers.
Open the front panel on the computer case, pull down the protective door on the optical drive if necessary, and find the manual ejection hole that is typically located to the left of the tray ejection button. Unfold the paperclip to make a straight 1- or 2-inch long part, insert the tip of that part into the hole, and slowly push in until you meet resistance. Gently push against the resistance to move the gear that opens the drive manually. Repeat this process until the tray opens enough for you to grab it with your fingers, and pull the tray open.
Pull the tip of the paperclip away from the hole, and make sure to stop pulling on the tray when you meet resistance. Remove the disc or object that caused the obstruction, and push the tray back into the drive. If the tray doesn't automatically close the next time you power on the computer, it indicates that the ejection mechanism is damaged and that you need to replace the drive.