Preventing driver hangs caused by TypeError: can't access dead object, when a document is removed at the moment we execute some script. Instead of hanging it should throw an exception. Fixes issue 7934