There are probably open sessions on the database you are attempting to bring offline. SQL Server is trying to roll back any existing workloads in-flight for that database. 

Issue the sp_who2 command from a new connection (master db) and view what's active. If you see activity, let it complete--or if you don't want the sessions to complete for whatever reason, issue the kill command for the spid(s).  

In the future, use this command:

ALTER DATABASE yourDBName SET OFFLINE WITH ROLLBACK IMMEDIATE;

To bring the db back online:

ALTER DATABASE yourDBName SET ONLINE