This will not count properly when there is more than one database matching given criteria.
Try something like:
DECLARE @names VARCHAR(MAX)
SET @names = ''
SELECT @names = @names + ', ' + name
FROM sys.databases WHERE is_auto_close_on = 1
IF LEN(@names) > 0
SET @names = 'Autoclose databases: ' + RIGHT(@names, LEN(@names) - 2)
SELECT COUNT(*) as [cnt], @names as [msg]
FROM sys.databases WHERE is_auto_close_on = 1