Please try the script to safely remove the disk, maybe you will find it useful :)
@echo off
cls
set tempfile="%TEMP%\tmp_disk.dsk"
cd %SystemRoot%\system32
echo.
echo ...:: Safely Remove Disk ::...
echo.
echo Select the disk volume number (if the disk has multiple volumes, select any of them)
echo.
echo.
echo list volume | diskpart | findstr /C:Volume /C:---
echo.
set /p volume=" Selected volume: "
echo.
echo select volume %volume% >>%tempfile%
echo offline disk >>%tempfile%
echo online disk >>%tempfile%
diskpart /s %tempfile% | findstr /C:"not valid"
if "%ERRORLEVEL%"=="1" (
echo Disk has been unlocked successfully. Try to safely remove it now...
pause
)
del /F %tempfile%
source
share