title: destroy directx device and swap chain
body: <p>I am encountering a strange issue I think involves <code>D3D11CreateDeviceAndSwapChain</code> I can create the device and swap chain however when the application exits and <code>-&gt;destroy</code> gets called on the swap chain, device, and device context a thread is still running. Commenting out this line the application terminates as expected.</p>
  
  <pre><code>featureLevel = D3D_FEATURE_LEVEL_11_0;
  result = D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, &amp;featureLevel, 1, D3D11_SDK_VERSION, &amp;swapChainDesc, &amp;m_swapChain, &amp;m_device, NULL, &amp;m_deviceContext);
  
  if(FAILED(result))
  {
  #ifdef _DEBUG
      log(logDEBUG) &lt;&lt; "Error at D3D11CreateDeviceAndSwapChain";
  #endif
      return false;
  }
  return true;
  </code></pre>
  
  <p>and the destruction:</p>
  
  <pre><code>if(m_swapChain)
  {
      m_swapChain-&gt;SetFullscreenState(false, NULL);
  }
  
  if(m_device)
  {
      m_device-&gt;Release();
  }
  
  if(m_deviceContext)
  {
      m_deviceContext-&gt;Release();
  }
  
  if(m_swapChain)
  {
      m_swapChain-&gt;Release();
  }
  </code></pre>
  
  <p>I am fairly confident that the issue is coming from this, but I am not 100% sure. stepping through the code i see that each Release gets called correctly. (the application will close properly if the first block is commented out.)</p>
  
  <p>Thanks for any insight regarding this issue. </p>