When we abort a transaction from the expired transactions reaper (or otherwise outside the transaction), we call code in ~TxnResources which calls _locker->endWriteUnitOfWork, then _recoveryUnit->abortWriteUnitOfWork. In the usual case of allowing a WUOW to go out of scope, we call recoveryUnit->abortUnitOfWork and then lockState->endWriteUnitOfWork. The second order is correct. Calling endWriteUnitOfWork releases locks, but some of the internal machinery of abortUnitOfWork may require resources protected by those locks. In particular, in BF-10436, aborting an insert() expected the WiredTigerRecordStore to be available, but a concurrent dropCollection caused it to be destroyed.
Note the incorrect same ordering is used in ~OplogSlotReserver.