It is unlikely that any command-line program would help in that case (even though there seems to be one: http://www.uwe-sieber.de/drivetools_e.html)
What you would need to find out is what process prevents you from removing the drive. You could use Process Explorer to do that. Start Process Explorer, click Find -> Find Handle or DLL -> enter your USB stick drive letter (like G:) and click Search. This will list processes that reference the USB drive.
Note that although it is possible to close a handle using Process Explorer ("freeing" the USB drive for Safe Removal) it is not recommended in most cases. It's better to simply exit the program that is using the drive.