There will be occasions where you need to work with the databases for SharePoint in SQL Server Management Studio. Backups, restores, etc... If you run into problems with there being existing connections to the databases preventing you from performing maintenance items, here’s a way to kill those database connections.
Management > Activity Monitor > View Processes
You’ll then have a list of all connections to the SQL Server. Sort the list so that the connections to the specific database you are working on are grouped together. Right-Click on a process, and select Kill Process.
Once all of those processes (and connection with it) are killed, you’ll be able to perform those maintenance items.