 					logger.debug("FIRING STREAM END");
 				}
 
+				// Forcibly fire a duration event that will end with the last tag we wrote.
+				// This ensures that we will properly terminate and trigger rewind logic in
+				// kdp/OSMF. If you come up short and end then it restarts erroneously.
+				var metadata:Object = new Object();
+				metadata.duration = (lastWrittenTime - indexHandler.getStreamStartTime()) - 0.5;
+				var durationTag:FLVTagScriptDataObject = new FLVTagScriptDataObject();
+				durationTag.objects = ["onMetaData", metadata];
+				dispatchEvent(new HTTPStreamingEvent(HTTPStreamingEvent.SCRIPT_DATA, false, false, 0, durationTag, FLVTagScriptDataMode.IMMEDIATE));
+				trace("Fired artificial duration of " + metadata.duration);
+
+
 				// For us, ending means ending the sequence, firing an onPlayStatus event,
 				// and then really ending.	
 				appendBytesAction(NetStreamAppendBytesAction.END_SEQUENCE);

								_timeCache_liveEdgeMinusWindowDuration = _timeCache_liveEdge - indexHandler.windowDuration;
							else
								_timeCache_liveEdgeMinusWindowDuration = 0;
							//trace("   o Perceived live stream (" + _timeCache_liveEdge + ", " + _timeCache_liveEdgeMinusWindowDuration + ")");						
							didValidUpdate = true;
						}
						else
						{
							//trace("   o Failed to perceive live stream, will retry later.");
						}
					}
					else
					{
						//trace("   o Perceived VOD stream.");
						_timeCache_liveEdge = 0;
						_timeCache_liveEdgeMinusWindowDuration = 0;
						didValidUpdate = true;

			CONFIG::LOGGING
			{
				logger.debug("NetStatus event:" + event.info.code);
				trace("" + (new Error()).getStackTrace());
				trace("end time is " + indexHandler.getStreamEndTime() + " duration = " + indexHandler.getStreamDuration() + " time= " + time);
			}

			switch(event.info.code)
			{
				case NetStreamCodes.NETSTREAM_BUFFER_EMPTY:					
