You need to close the application which Windows thinks is still using the device. For, example, if you've got an image-viewing program open and it's displaying a file from the flash drive, you won't be able to remove it. Even having a Windows Explorer window open, displaying the presence of the drive, can cause the problem.
However it can be tricky finding out what's holding on to the flash drive. (It could, for example, be that you anti-virus program is scanning it). If you've got Unlocker installed you can right-click on the drive and select 'Unlocker' to see what processes are accessing it. You can then close them normally or use the 'Kill Process' option in Unlocker:
http://www.filehippo.com/download_unlocker/
If all else fails, of course, you simply switch your computer off and then remove the flash drive. Logging off and then on again is quicker though and seems to work for some people.