Call PrepareShutdown in the dtor just in case Close() hasn't been called

Bug: b/277912909
Change-Id: I0074de59f5d16d500795589a0c94ff4840ffe57a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/302384
Reviewed-by: Florent Castelli <orphis@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39932}
diff --git a/pc/peer_connection.cc b/pc/peer_connection.cc
index d9602ea..4839fcf 100644
--- a/pc/peer_connection.cc
+++ b/pc/peer_connection.cc
@@ -543,6 +543,10 @@
     sdp_handler_->PrepareForShutdown();
   }
 
+  // In case `Close()` wasn't called, always make sure the controller cancels
+  // potentially pending operations.
+  data_channel_controller_.PrepareForShutdown();
+
   // Need to stop transceivers before destroying the stats collector because
   // AudioRtpSender has a reference to the LegacyStatsCollector it will update
   // when stopping.