Saving a reference to the LocalMediaStream
like asgoth suggests is correct, but for me in Chrome 47. localStream.stop();
gave me an error:
Uncaught TypeError: localStream.stop is not a function
I got it to work by calling:
localStream.getVideoTracks()[0].stop();