If your program is complaining that the DB is in use, that is so because the SQL Server tells it it is. So, use the SQL Server Tools to find out who is using the DB. Note that you can only close DBs whose authentication you have, and if an external user is using the DB or just forgot to close it, you are out of luck and must close the connection manually as the SQL Server's operator.