Cant restore database from A to B using any method in SSMS GUI
I would try:

USE master;
GO
ALTER DATABASE B SET OFFLINE WITH NO_WAIT


Note this will make the database inaccessible but guess that doesn't matter if you are going to restore over the top of it anyway.

If that fails then:

USE master;
GO
ALTER DATABASE B SET OFFLINE WITH ROLLBACK IMMEDIATE


But if a big transaction is in progress then it could take a long time to rollback.