   teardown: ->
     if (@streamPublisher)
       @streamPublisher = false
+      @stream.dump.end( () =>
+        console.log "Dump finished and closed " + @stream.name
+      );
       @emit "stream_unpublished", @stream
     if @isTearedDown
       console.log "[rtmp] already teared down"

            when 9  # Video Message (incoming)
              videoData = parseVideoMessage @stream, rtmpMessage.body
              if videoData.nalUnitGlob?
                if not @isFirstVideoReceived
                  @emit 'video_start', @stream
                  @isFirstVideoReceived = true

            when 8  # Audio Message (incoming)
              audioData = parseAudioMessage @stream, rtmpMessage.body
              if audioData.adtsFrame?

                fileHeader = new Buffer(4 * 4)
                
                fileHeader.writeUInt32LE(8, 0)
                fileHeader.writeUInt32LE(rtmpMessage.timestamp, 4)
                fileHeader.writeUInt32LE(audioData.adtsFrame.length, 8)
                fileHeader.writeUInt32LE(0, 12)

                @stream.dump.write fileHeader

                @stream.dump.write audioData.adtsFrame
                if not @isFirstAudioReceived
                  @emit 'audio_start', @stream
                  @isFirstAudioReceived = true
