I am using MS SQL server 2008, unable to rename a database... I closed all the applications. But could not able to rename. 
The error message appears as 
TITLE: Microsoft SQL Server Management Studio
------------------------------
Unable to rename testdb1. (ObjectExplorer)
------------------------------
ADDITIONAL INFORMATION:
Rename failed for Database 'test'. (Microsoft.SqlServer.Smo)
	For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10…-
	0026+)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExce
	ptionText&EvtID=Rename+Database&LinkId=20476
------------------------------
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
------------------------------
The database could not be exclusively locked to perform the operation. (Microsoft SQL Server, Error: 5030)
	For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10…
	nkId=20476
 Live to Learn!
  Live to Learn!
     
Run the query :
Run the query :
use master
exec sp_who
This will list all the processes with SPID, that running in the SQL Server Instance
Note the SPID of the process which uses the database you wish to rename.
For e.g. if SPID is 52
Then execute the query : KILL 52