Rename an SQL Server Database that could not be exclusively locked

Quick note about how to rename an SQL Server database that could not be exclusively locked (because it has open connections to it):

ALTER DATABASE currentDbName SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
GO
EXEC sp_renamedb N'currentDbName', N'newDbName';
GO
ALTER DATABASE newDbName SET MULTI_USER WITH ROLLBACK IMMEDIATE;
GO