• I usually do it this way, because once the database is dropped there is no way to connect to it.

    use master;

    alter database [MyDb] set offline with rollback immediate;

    alter database [MyDb] set online with rollback immediate;

    drop database [MyDb];

    I set it back online so that when the database is dropped the database files are deleted. If you drop it while the database is offline the files are not deleted.

    It's theoretically possible that someone could connect when you bring it back online and before the database is dropped, but I have never seen that happen when the commands are executed in one batch like the script above.