First, you "unmount" it, but leave it plugged in. This is the equivalent of "Safely Remove Device" in Windows. you can unmount it using the command
umount /dev/sdx
"x" can be any letter, but it will usually be "f" for the first Flash drive plugged in. You can view the mounted devices by using the command
mount
This will return a result like:
/dev/sdf on /media/disk type vfat (rw,nosuid,nodev,uhelper=hal,uid=1000,codepage=437,iocharset=utf8)
for the Flash drive.
To format it, execute the command
mkfs.vfat /dev/sdx
You can then remount the device.