Avoid race in Call destructor

Don't update histograms until we're sure process threads won't call into
the instance being destructed, trying to update stats.

BUG=webrtc:6103

Review-Url: https://codereview.webrtc.org/2151433002
Cr-Commit-Position: refs/heads/master@{#13461}
diff --git a/webrtc/call/call.cc b/webrtc/call/call.cc
index dfb1879..51e0cce 100644
--- a/webrtc/call/call.cc
+++ b/webrtc/call/call.cc
@@ -265,8 +265,6 @@
 Call::~Call() {
   RTC_DCHECK(!remb_.InUse());
   RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
-  UpdateSendHistograms();
-  UpdateReceiveHistograms();
   RTC_CHECK(audio_send_ssrcs_.empty());
   RTC_CHECK(video_send_ssrcs_.empty());
   RTC_CHECK(video_send_streams_.empty());
@@ -282,6 +280,12 @@
   module_process_thread_->DeRegisterModule(call_stats_.get());
   module_process_thread_->Stop();
   call_stats_->DeregisterStatsObserver(congestion_controller_.get());
+
+  // Only update histograms after process threads have been shut down, so that
+  // they won't try to concurrently update stats.
+  UpdateSendHistograms();
+  UpdateReceiveHistograms();
+
   Trace::ReturnTrace();
 }