title: Web camera light stays on after stream is stopped
body: <p>I am building a project that captures an image from the webcam in the browser. After the image is taken, I no longer need to use the camera, so I am trying to stop it with the following function:</p>
  
  <pre class="lang-js prettyprint-override"><code>function stopCamera(container) {
      console.log("Stopping the camera.");
  
      video = container.querySelector('.video-streamer');
  
      console.log(video);
  
      video.srcObject = null;
  
      navigator.mediaDevices.getUserMedia({ video: true }).then(
          function (stream) {
              console.log(stream.getTracks().length);
  
              stream.getTracks().forEach(function (track) {
                  console.log("Found a stream that needs to be stopped.")
                  track.stop();
              });
  
              console.log(stream.getTracks().length);
          }).catch(
              function (error) {
                  console.log('getUserMedia() error', error);
              });
  
  }
  </code></pre>
  
  <p>However, even after the function is called, the webcam access light stays on, and I see that the browser (both Firefox and Chrome) still show that the page is using the camera.</p>
  
  <p>What is missing in the code above?</p>