             callbacks.success()
 
 
+  handleCollaborationEndedForHost: ->
+
+    return  unless @stateMachine.state in ['Ending']
+
+    @rtm.once 'RealtimeManagerWillDispose', =>
+      @chat.emit 'CollaborationEnded'
+      @chat.destroy()
+      @chat = null
+      @statusBar.emit 'CollaborationEnded'
+
+    @rtm.once 'RealtimeManagerDidDispose', =>
+      kd.utils.defer @bound 'prepareCollaboration'
+
+    @cleanupCollaboration()
+
+
   endCollaborationForParticipant: (callbacks) ->
 
     @broadcastMessage { type: 'ParticipantWantsToLeave' }

    @rtm.once 'RealtimeManagerDidDispose', =>
      @rtm = null
      delete @stateMachine
      @prepareCollaboration  if @amIHost

    @rtm.dispose()


    if @amIHost
      @endCollaborationForHost
        success: =>
          @modal?.destroy()
          @handleCollaborationEndedForHost()

    else
      @endCollaborationForParticipant
