Roku RAF Integration Issue

I am working on integrating the RAF into a channel. When I click the play the ad and video plays successfully but the screen doesnt close and I see the loading screen. Any help would be appreciated.

Library "Roku_Ads.brs"

Function PlayVideoContent(episode as object)
  videoScreen = CreateObject("roVideoScreen")
  port = CreateObject("roMessagePort")
  videoScreen.SetMessagePort( port )

  metaData = {
    ContentType: episode.contentType,
    VideoId: episode.id,
    Title: episode.title,
    Description: episode.description,
    length: episode.length,
    PlayStart: episode.PlayStart,
    Stream: {
      Url: episode.url
    }
    Bitrates:  episode.bitrates
    StreamFormat: episode.streamformat
    SubtitleUrl: episode.subtitle
  }

  videoScreen.SetPositionNotificationPeriod(1)
  videoScreen.SetContent(metaData)
  videoScreen.show()

    while true
        msg = wait(0, port)
        if type(msg) = "roVideoScreenEvent" then
          print "showVideoScreen | msg = "; msg.getMessage() " | index = "; msg.GetIndex()
          if msg.isScreenClosed()
            print "Screen closed"
            exit while
          else if msg.isfullresult()
            RegDelete(episode.id)
              details = CreateObject("roAssociativeArray")
              details.eventName = "Video Played"
              details.videoID = episode.id.tostr()
              details.videoTitle = episode.title
              details.videoSecondsPlayed = nowpos.tostr()
              details.videoPercentPlayed = percent.tostr()
              details.videoViewCompleted = "View Completed"
              m.Analytics.AddEvent("Video Played", details)
          else if msg.isPartialResult()
            nowpos = RegRead(episode.id)
            if nowpos <> invalid
              nowpos = RegRead(episode.id).toInt()
              percent = FIX(nowpos/episode.length * 100)
              details = CreateObject("roAssociativeArray")
              details.videoID = episode.id.tostr()
              details.eventName = "Video Played Partial"          
              details.videoTitle = episode.title
              details.videoSecondsPlayed = nowpos.tostr()
              details.videoPercentPlayed = percent.tostr()
              details.videoViewCompleted = "Partial View"
              m.Analytics.AddEvent("Video Played Partial", details)
            else
              print "invalid exit"
            endif
          else if msg.isRequestFailed() then
            showVideoFailureMessage()
              details = CreateObject("roAssociativeArray")
              details.eventName = "Video Failed"
              details.videoID = episode.id.tostr()
              details.videoTitle = episode.title
              details.videoViewCompleted = "Video Failed"
              m.Analytics.AddEvent("Video Failed", details)        
            'print "Video request failure: "; msg.GetIndex(); " " msg.GetData() 
          else if msg.isStatusMessage()
            print "Video status: "; msg.GetIndex(); " " msg.GetData() 
          else if msg.isButtonPressed()
            print "Button pressed: "; msg.GetIndex(); " " msg.GetData()
          else if msg.isPlaybackPosition() then
            nowpos = msg.GetIndex()
            RegWrite(episode.id, nowpos.toStr())
            percent = FIX(nowpos/episode.length * 100)
          else if msg.isPaused() then
            details = CreateObject("roAssociativeArray")
            details.eventName = "Video Paused"
            details.videoID = episode.id.tostr()
            details.videoTitle = episode.title
            details.videoSecondsPlayed = nowpos.tostr()
            details.videoViewCompleted = "Video Paused"
            m.Analytics.AddEvent("Video Paused", details)         
          else if msg.isResumed() then
            details = CreateObject("roAssociativeArray")
            details.eventName = "Video Resumed"
            details.videoID = episode.id.tostr()
            details.videoTitle = episode.title
            details.videoSecondsPlayed = nowpos.tostr()
            details.videoViewCompleted = "Video Resumed"
            m.Analytics.AddEvent("Video Resumed", details)           
          end if
        else
          print "Unexpected message class: "; type(msg)
        end if
      end while
  return videoScreen
End Function
    
Sub PlayContentWithAds(episode as Object)
    canvas = CreateObject("roImageCanvas")
    canvas.SetLayer(1, {color: "#000000"})
    canvas.SetLayer(2, {text: "Loading..."})
    canvas.Show()

    adIface = Roku_Ads()
    print "Roku_Ads library version: " + adIface.getLibVersion()
    ' Normally, would set publisher's ad URL here.  Otherwise uses default Roku ad server (with single preroll placeholder ad)
    'adIface.setAdUrl()

    adPods = adIface.getAds()
    playContent = adIface.showAds(adPods) ' show preroll ad pod (if any)

    curPos = 0
    if playContent
        videoScreen = PlayVideoContent(episode)
    end if

    while playContent 
        videoMsg = wait(0, videoScreen.GetMessagePort())
        if type(videoMsg) = "roVideoScreenEvent"
            if videoMsg.isStreamStarted()
                canvas.ClearLayer(2)
            end if
            if videoMsg.isPlaybackPosition()
                ' cache current playback position for resume after midroll ads
                curPos = videoMsg.GetIndex()
                RegWrite(episode.id, curPos.toStr())
                percent = FIX(curPos/episode.length * 100)
            end if
            'check for midroll/postroll ad pods
            adPods = adIface.getAds(videoMsg)
            if adPods <> invalid and adPods.Count() > 0
                ' stop video playback to prepare for midroll ad render
                videoScreen.Close()
                playContent = adIface.showAds(adPods)
                if playContent
                    ' resume video playback after midroll ads
                    episode.PlayStart = curPos
                    videoScreen = PlayVideoContent(episode)
                end if
                ' if !playContent, User exited ad view, returning to content selection
            end if ' adPods <> invalid

        end if ' roVideoScreenEvent
    end while
    if type(videoScreen) = "roVideoScreen" then videoScreen.Close()
End Sub