This script opens a little cursor that will clean out connections to any DBs you specify. It will release SPIDs that are active on a DB or which are locking a related SPID. I found the base script some time ago -I wish I remembered the author or location- but I've modified it ever so slightly to provide for a good package that can be used prior to starting a DB restore for example.
Feel free to play with it and adapt it to whatever needs you may have. I've used this, at times, to kill SPIDs which were causing blocking conditions. You should be able to easily modify it to go after very specific conditions.