Thanks, another option i use often is to set the DB to Single user mode and rolling back any uncommitted transaction and when done enable it for connection.
ALTER DATABASE Test SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
--ACTION goes here--
ALTER DATABASE Test SET MULTI_USER;