diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp
index 363bc43803d8a55b406dfe47dbc53d4257d51780..e9641344d62a29adf89fa3f5e0ed9c48bca3e713 100644
--- a/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp
+++ b/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp
@@ -133,6 +133,9 @@ QWinRTBluetoothDeviceDiscoveryWorker::QWinRTBluetoothDeviceDiscoveryWorker(QBlue
 {
     qRegisterMetaType<QBluetoothDeviceInfo>();
 
+#ifdef CLASSIC_APP_BUILD
+    CoInitialize(NULL);
+#endif
     HRESULT hr = GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Devices_Bluetooth_BluetoothDevice).Get(), &m_deviceStatics);
     Q_ASSERT_SUCCEEDED(hr);
     hr = GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Devices_Bluetooth_BluetoothLEDevice).Get(), &m_leDeviceStatics);
@@ -142,6 +145,9 @@ QWinRTBluetoothDeviceDiscoveryWorker::QWinRTBluetoothDeviceDiscoveryWorker(QBlue
 QWinRTBluetoothDeviceDiscoveryWorker::~QWinRTBluetoothDeviceDiscoveryWorker()
 {
     stop();
+#ifdef CLASSIC_APP_BUILD
+    CoUninitialize();
+#endif
 }
 
 void QWinRTBluetoothDeviceDiscoveryWorker::start()
diff --git a/src/bluetooth/qbluetoothserver_winrt.cpp b/src/bluetooth/qbluetoothserver_winrt.cpp
index f478dc936888ecb7b3b752f31299d15a4dac3118..08aa45b4141d74419df3adf6c358f47fee384f69 100644
--- a/src/bluetooth/qbluetoothserver_winrt.cpp
+++ b/src/bluetooth/qbluetoothserver_winrt.cpp
@@ -73,6 +73,9 @@ QHash<QBluetoothServerPrivate *, int> __fakeServerPorts;
 QBluetoothServerPrivate::QBluetoothServerPrivate(QBluetoothServiceInfo::Protocol sType)
     : maxPendingConnections(1), serverType(sType), m_lastError(QBluetoothServer::NoError), socket(0)
 {
+#ifdef CLASSIC_APP_BUILD
+    CoInitialize(NULL);
+#endif
     socket = new QBluetoothSocket(QBluetoothServiceInfo::RfcommProtocol);
 }
 
@@ -82,6 +85,12 @@ QBluetoothServerPrivate::~QBluetoothServerPrivate()
     __fakeServerPorts.remove(this);
     if (socket)
         delete socket;
+#ifdef CLASSIC_APP_BUILD
+    // If we do not reset that pointer, socketListener will go out of scope after CoUninitialize was
+    // called, which will lead to a crash.
+    socketListener = nullptr;
+    CoUninitialize();
+#endif
 }
 
 bool QBluetoothServerPrivate::isListening() const