• presuming this is a user database you are trying to restore?

    run select * from master..sysprocesses where db_name(dbid) = 'your database'

    kill any spids this returns and run our restore (in the same batch)

    If the connections keep getting to the database before you can run

    alter database your database set offline with rollback immediate;

    then your restore in the same batch

    ---------------------------------------------------------------------