/* To automatically close a db when no users are accessing it */
ALTER DATABASE pubs SET AUTO_CLOSE ON
go
However when u use the db , it will be opened again !
so what is the exact test that u are doing?
consider putting db in dbo use only mode.
sp_dboption pubs ,'dbo use only' , true
go