This error can be a real pain when having to restore backup files between different servers, or even your local machine. One way to be sure to fix this is to just bulldoze your way through the issue.
But – make sure you aren’t stepping on anyone else’s toes when doing this!
First, make sure you’re using [master] database, or you might be the connection that’s using the database.
USE MASTER
GO
Then find out which process is using the database.
exec sp_who2
Then ask the user nicely to log off. Or, just kill the connection outright 
KILL {spid}
GO
Now restore your database.