Fix potential deadlock in shutdown in HistoricalRegistry am: 4a2d4ddf6e am: 5784a50609

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13082067

Change-Id: Id288f6c5f92dd44d9a92b638156a2c5388e93de2