Error renaming database in SQL Server 2008

I right clicked on a database in SQL Server Management Studio and selected rename. Gave it a new name and hit enter. Eventually this error comes back:

The database could not be exclusively locked to perform the operation.

The better way to rename the database is using SQL running these queries:

Continue reading