One of the easiest and fastest ways to clear all connections to a database is to use the following code (change the DB name, of course)... read the comments because there is a danger in doing so... and, keep in mind that this kills EVERYTHING with great prejudice. Any long-running transactions will take time to rollback. It also kills connections made by jobs. I'll say it again... it KILLS EVERYTHING. Use with care.
USE [master]
GO
--===== This kills everything except the connection running this command.
ALTER DATABASE [YourDbNameHere] SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
--===== This sets it back to normal so that, if you lose the connection,
-- some app doesn't grab the only connection locking you out from it.
-- As an alternative, you could set it to restricted users but that
-- will also still let some apps in if they inappropriately have
-- the restricted privs
ALTER DATABASE [YourDbNameHere] SET MULTI_USER;
--===== Then, do your stuff immediately and without delay.
--Jeff Moden
Change is inevitable... Change for the better is not.