How to Kill Active Connections to SQL Server database

ALTER DATABASE databasename SET SINGLE_USER WITH ROLLBACK IMMEDIATE

ALTER DATABASE databasename SET MULTI_USER