Free USB Guard will alert you in case a flash drive (or another external drive) is attached or a disc is present in the DVD reader during the shutdown or log off process.
The shutdown / log off will be blocked allowing you to take out the flash drive or the DVD disc.
Note about external HDD: Free USB Guard can detect them only if they are plugged after the software has been started. Otherwise, you can select them manually in the menu "monitor the presence of these drives".
Free USB Guard is freeware. However, if you enjoy using Free USB Guard and would like to help support its development, please consider making a donation.