         @emit "save"
 
   attachEvents: ->
+
+    {snapTitle} = @getOptions()
+
+    @on "KDObjectWillBeDestroyed", => @unsetVideoStream()
+
     @on "viewAppended", =>
       @context = @picture.getElement().getContext "2d"
       @getUserMedia()


    if navigator.getUserMedia
      navigator.getUserMedia video: yes, (stream)=>
        @setVideoStream (window.URL and window.URL.createObjectURL stream) or stream
      , _onError
    else _onError notSupported: yes

    @picture.setDomAttributes size
    @setSize size

  unsetVideoStream: ->
    video = @video.getElement()
    video.pause()
    KDWebcamView.setVideoStreamVendor video, ""
    @localMediaStream?.stop()

  setVideoStream: (stream)->
    video = @video.getElement()
    KDWebcamView.setVideoStreamVendor video, stream
