Change shutdown order when detecting external destruction of debugger documents
This is not allowed, however, we still test this situation in the unit tests, and it caused a crash when running on Emscripten.
This commit changes the shutdown order so that the debugger documents are released before emitting the log message. This prevents the log call from calling back into the debugger and eventually leading to a crash in `ElementLog::AddLogMessage`.