cmdagent and i don't know where to put this

I was frustrated by windows telling me that a USB jump drive was in use when I was attempting to eject it and I knew I had no open handles on the drive.

I used a program to locate the fact that cmdagent had a lock on the drive.

I don’t care why, but it was not letting the drive be ejected.

I killed the handles.

How do I prevent that from happening in the future?