Poor SQL Server performance when management studio closed
The database you are querying probably has "auto close" enabled.

The connection from SSMS stops the database closing. When you close SSMS, the database closes. A subsequent call requires it to be opened.

Auto close is the default for SQL Server Express and is not a good idea:


http://blogs.msdn.com/b/buckwoody/archive/2009/06/24/sql-server-best-practices-autoclose-should-be-off.aspx
http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/sql-server-auto-close
https://stackoverflow.com/questions/706732/what-is-the-auto-close-option-when-creating-a-new-database-in-sql-server-2008