Could see if the problem exists when you boot to a USB stick/drive or while the Windows boot menu is up, if you use one -- if the drive closes the same way then reboot the same way, open the drive tray, & immediately power off... that way with the tray open you can try blowing things out with compressed/canned air.
You can open/close the tray in Windows, so could be a software problem -- if it acts up when Windows isn't running that's eliminated. Most optical drives have a switch that closes the tray when you push on it, &/or if it doesn't/can't open all the way -- might get lucky & there's something blocking the tray from opening all the way or causing the switch to stick, e.g. dirt/debris. When you're in Windows you don't want to just power off with the power supply or power strip switch because Windows won't have a chance to write everything to disk & you'll likely get disk errors as a result -- running off a USB stick or during the boot menu you won't have that problem.
Could always just replace the drrive of course -- I've seen DVD writers on sale for as low as $13 U.S. -- but figured if you were inclined to go that route you would have already.