diff --git a/third-party/pjproject/patches/0023-Flush_pending_tx_at_tls_shutdown.patch b/third-party/pjproject/patches/0023-Flush_pending_tx_at_tls_shutdown.patch
new file mode 100644
index 0000000000000000000000000000000000000000..6654435af61dfa573d85057e5326c6c20adbba64
--- /dev/null
+++ b/third-party/pjproject/patches/0023-Flush_pending_tx_at_tls_shutdown.patch
@@ -0,0 +1,40 @@
+diff --git a/pjsip/src/pjsip/sip_transport_tls.c b/pjsip/src/pjsip/sip_transport_tls.c
+index 2c969a31c..73917945e 100644
+--- a/pjsip/src/pjsip/sip_transport_tls.c
++++ b/pjsip/src/pjsip/sip_transport_tls.c
+@@ -175,6 +175,7 @@ static void tls_on_destroy(void *arg);
+ 
+ static void wipe_buf(pj_str_t *buf);
+ 
++static void tls_flush_pending_tx(struct tls_transport *tls);
+ 
+ static void tls_perror(const char *sender, const char *title,
+                        pj_status_t status, pj_str_t *remote_name)
+@@ -244,7 +245,7 @@ static void tls_init_shutdown(struct tls_transport *tls, pj_status_t status)
+         tls->close_reason = status;
+ 
+     if (tls->base.is_shutdown || tls->base.is_destroying)
+-        return;
++        goto End;
+ 
+     /* Prevent immediate transport destroy by application, as transport
+      * state notification callback may be stacked and transport instance
+@@ -277,7 +278,7 @@ static void tls_init_shutdown(struct tls_transport *tls, pj_status_t status)
+     /* check again */
+     if (tls->base.is_shutdown || tls->base.is_destroying) {
+         pjsip_transport_dec_ref(&tls->base);
+-        return;
++        goto End;
+     }
+ 
+     /* We can not destroy the transport since high level objects may
+@@ -289,6 +290,9 @@ static void tls_init_shutdown(struct tls_transport *tls, pj_status_t status)
+ 
+     /* Now, it is ok to destroy the transport. */
+     pjsip_transport_dec_ref(&tls->base);
++
++End:
++    tls_flush_pending_tx(tls);
+ }
+ 
+