How to delete mdf file in use but not attached?
Try to set the database (returned by the query in sys.master_files) Offline with 

Alter database [YourDB] set offline;


If the database is still seen in the dmv, it may still be possible to set it as offline (and then you'll be able to delete the file).

But if you want to delete the file, you could also just try to drop the database

Drop database [YourDB];