diff --git a/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboardView.java b/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboardView.java
index b4fa86dd5786bb6d4836a70f1a04bd025b7e628c..be7644fb566298670aa24d0a29aacaa9257c4d5f 100644
--- a/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboardView.java
@@ -159,7 +159,7 @@ public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel
 
     @Override
     public boolean dismissMoreKeysPanel() {
-        if (mIsDismissing) return false;
+        if (mIsDismissing || mController == null) return false;
         mIsDismissing = true;
         final boolean dismissed = mController.dismissMoreKeysPanel();
         mIsDismissing = false;
diff --git a/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java b/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java
index 8a29dcc13b097663836545e8799e879c1adc060e..19287e3f32b9dac5dbf590fb3f971e06f5705df6 100644
--- a/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java
+++ b/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java
@@ -167,7 +167,7 @@ public class MoreSuggestionsView extends KeyboardView implements MoreKeysPanel {
 
     @Override
     public boolean dismissMoreKeysPanel() {
-        if (mIsDismissing) return false;
+        if (mIsDismissing || mController == null) return false;
         mIsDismissing = true;
         final boolean dismissed = mController.dismissMoreKeysPanel();
         mIsDismissing = false;
diff --git a/java/src/com/android/inputmethod/latin/suggestions/SuggestionsView.java b/java/src/com/android/inputmethod/latin/suggestions/SuggestionsView.java
index 3d593aaa7d21383ca233aceef9af14e733734c00..40e54a474950dd7b083ca2ef490226411a51c492 100644
--- a/java/src/com/android/inputmethod/latin/suggestions/SuggestionsView.java
+++ b/java/src/com/android/inputmethod/latin/suggestions/SuggestionsView.java
@@ -884,5 +884,6 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
         super.onDetachedFromWindow();
         mHandler.cancelAllMessages();
         hidePreview();
+        dismissMoreSuggestions();
     }
 }