What to check for when receiving intermittent error on Kill Command
When you execute srv.KillAllProcesses; SMO will just launch a KILL &lt;spid&gt; for every process connected to the database.

Once those kill commands are executed, some transactions may still be rolling back. I'm not sure what may be going on behind the scenes that puts your database in the state returning your error message when transactions are still rolling back but in any case that call isn't needed.

Calling only srv.KillDatabase; will execute a ALTER DATABASE [dbname] SET SINGLE_USER WITH ROLLBACK IMMEDIATE; before attempting to drop the database using DROP DATABASE, effectively killing/rolling back any active transactions.

It's the ALTER DATABASE statement that is returning the error you receive.

This can be verified by looking at a profiler trace or extended event target.

Have a look at Set a Database to Single-user Mode


  If other users are connected to the database at the time that you set
  the database to single-user mode, their connections to the database
  will be closed without warning.


There is no reason to kill the processed first and you should probably remove that line of code