Hello, @Szymon Rabiza and all.
Further to the archived thread at <https://social.technet.microsoft.com/Forums/en-US/f4460a73-6a42-47f8-950b-2f18e03c0a7e/impossible-to-remove-a-persistent-network-drive-mapping-when-logged-on-disconnected?forum=win10itprogeneral> and the above answers; you may wish to use the following commands.
Net Use z: /Delete
Mountvol z: /d
if not exist z:\ (Net Use z: \servername\share /Persistent:YES)
These three lines can be concatenated into a single command line expression, by using ampersands (&).
I have struggled for the last six months and have developed an elaborate batch file to remap my home network drives on my laptop; as Windows 10 doesn't always find them again. Today, the referenced archived thread pointed me to using both Net Use /d and Mountvol /d — as a pair. Kudos to @Giacomo and @Grajon, as the net use and mountvol pair obviates the need to stop and restart file Explorer; which itself introduces other (potential) issues!
PS. Per the original/archived thread, I too suspect this is an unresolved Windows 10 bug.
You can only check if the mapped network drive is already mounted, not sure if you can check if it's in use.