I was getting this error when trying to drop a database:
Cannot drop database "MyDatabaseName" because it is currently in use.
I tried the sp_who command to see if there was anything holding on to the DB that I hadn't disconnected from. Couldn't see anything.
drop database MyDatabaseName kept on failing.
Eventually I closed SQL Server Management Studio (SSMS) and reopened it and the drop command then worked immediately. No idea why this happened but this was the solution.