diff --git a/indra/newview/llfloaterimnearbychat.cpp b/indra/newview/llfloaterimnearbychat.cpp
index 6d2dc6d4b13f4353e7514016a44a96d2a19428ca..71e62e5694daef65d6949a25e028cc2b23b1c761 100644
--- a/indra/newview/llfloaterimnearbychat.cpp
+++ b/indra/newview/llfloaterimnearbychat.cpp
@@ -295,7 +295,7 @@ void LLFloaterIMNearbyChat::setVisible(BOOL visible)
 {
 	LLFloaterIMSessionTab::setVisible(visible);
 
-	if(visible)
+	if(visible && isMessagePaneExpanded())
 	{
 		removeScreenChat();
 	}
@@ -306,7 +306,7 @@ void LLFloaterIMNearbyChat::setVisibleAndFrontmost(BOOL take_focus, const LLSD&
 {
 	LLFloaterIMSessionTab::setVisibleAndFrontmost(take_focus, key);
 
-	if(matchesKey(key))
+	if(!isTornOff() && matchesKey(key))
 	{
 		LLFloaterIMContainer::getInstance()->selectConversationPair(mSessionID, true, take_focus);
 	}
@@ -632,6 +632,10 @@ void LLFloaterIMNearbyChat::sendChat( EChatType type )
 	if (gSavedSettings.getBOOL("CloseChatOnReturn"))
 	{
 		stopChat();
+		if (isTornOff())
+		{
+			closeHostedFloater();
+		}
 	}
 }