diff --git a/indra/newview/llimfloater.cpp b/indra/newview/llimfloater.cpp
index a506f0f9f3f6e529953b0a35a0527ab64da68493..23c97c5345c5782016a33df835ee7ba096a7f394 100644
--- a/indra/newview/llimfloater.cpp
+++ b/indra/newview/llimfloater.cpp
@@ -118,6 +118,35 @@ void LLIMFloater::refresh()
 	}
 }
 
+// virtual
+void LLIMFloater::onClickCloseBtn()
+{
+	LLIMModel::LLIMSession* session = LLIMModel::instance().findIMSession(
+				mSessionID);
+
+	if (session == NULL)
+	{
+		llwarns << "Empty session." << llendl;
+		return;
+	}
+
+	bool is_call_with_chat = session->isGroupSessionType()
+			|| session->isAdHocSessionType() || session->isP2PSessionType();
+
+	LLVoiceChannel* voice_channel = LLIMModel::getInstance()->getVoiceChannel(mSessionID);
+
+	if (is_call_with_chat && voice_channel != NULL
+			&& voice_channel->isActive())
+	{
+		LLSD payload;
+		payload["session_id"] = mSessionID;
+		LLNotificationsUtil::add("ConfirmLeaveCall", LLSD(), payload, confirmLeaveCallCallback);
+		return;
+	}
+
+	LLIMConversation::onClickCloseBtn();
+}
+
 /* static */
 void LLIMFloater::newIMCallback(const LLSD& data)
 {
@@ -407,8 +436,7 @@ void LLIMFloater::addSessionParticipants(const uuid_vec_t& uuids)
 		bool is_voice_call = voice_channel != NULL && voice_channel->isActive();
 
 		// then we can close the current session
-		gIMMgr->leaveSession(mSessionID);
-		LLIMConversation::onClose(false);
+		onClose(false);
 
 		// Start a new ad hoc voice call if we invite new participants to a P2P call,
 		// or start a text chat otherwise.
@@ -667,29 +695,6 @@ LLIMFloater* LLIMFloater::getInstance(const LLUUID& session_id)
 
 void LLIMFloater::onClose(bool app_quitting)
 {
-	LLIMModel::LLIMSession* session = LLIMModel::instance().findIMSession(
-				mSessionID);
-
-	if (session == NULL)
-	{
-		llwarns << "Empty session." << llendl;
-		return;
-	}
-
-	bool is_call_with_chat = session->isGroupSessionType()
-			|| session->isAdHocSessionType() || session->isP2PSessionType();
-
-	LLVoiceChannel* voice_channel = LLIMModel::getInstance()->getVoiceChannel(mSessionID);
-
-	if (is_call_with_chat && voice_channel != NULL
-			&& voice_channel->isActive())
-	{
-		LLSD payload;
-		payload["session_id"] = mSessionID;
-		LLNotificationsUtil::add("ConfirmLeaveCall", LLSD(), payload, confirmLeaveCallCallback);
-		return;
-	}
-
 	setTyping(false);
 
 	// The source of much argument and design thrashing
@@ -1278,7 +1283,7 @@ void LLIMFloater::confirmLeaveCallCallback(const LLSD& notification, const LLSD&
 	const LLSD& payload = notification["payload"];
 	LLUUID session_id = payload["session_id"];
 
-	LLFloater* im_floater = LLFloaterReg::findInstance("impanel", session_id);
+	LLFloater* im_floater = findInstance(session_id);
 	if (option == 0 && im_floater != NULL)
 	{
 		im_floater->closeFloater();
diff --git a/indra/newview/llimfloater.h b/indra/newview/llimfloater.h
index 2e8fc84746ec583324e0619de47e0c7b72fee643..2ac11ded20af49ab69740291a1252383c14ebf1d 100644
--- a/indra/newview/llimfloater.h
+++ b/indra/newview/llimfloater.h
@@ -132,6 +132,8 @@ class LLIMFloater
 
 	/*virtual*/ void refresh();
 
+	/*virtual*/ void onClickCloseBtn();
+
 	// Update the window title, input field help text, etc.
 	void updateSessionName(const std::string& ui_title, const std::string& ui_label);