ALTER DATABASE <dbname> SET OFFLINE WITH ROLLBACK IMMEDIATE
In some cases you might get an error saying:
ALTER DATABASE failed because a lock could not be placed on database 'dbname' Try again later.
After you get this error, run
Look for the database in the result and find the SPID for that connection, then run
That should do the trick!