In SQL Server Management Studio, right click the database, Tasks > Take Offline
If it seems to take too long, see Long wait-time when taking SQL Server database offline | Degree Blog:
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