Detection of "Safely remove hardware" was used

Hello,

we use the RTX RTOS and USB MSD function to get access to an internal eMMC/SD card  that is connected to a Corex M7 CPU.

When the user does a "Safely remove hardware" on the PC: is it possible to detect this event in the microcontroller firmware?

When I do this for a standard USB-Stick, the device is removed and is not visible as a drive anymore.

If I do this for the drive of my embedded eMMC, Windows tells me that I can now safely remove the device, but the drive is still present and I can access it. So I assume that windows sends something like a "stop" command to the drive, and I need to do something in the firmware when I receive this. Is there a function that I can use to check that status?

Regards