diff --git a/src/dialogs.py b/src/dialogs.py
index 999359757a95d4c33118de66d0e20bca31f6f19b..bb7a3bb510d90d175076b3b46dad4c48ac4fdf28 100644
--- a/src/dialogs.py
+++ b/src/dialogs.py
@@ -2832,7 +2832,7 @@ class PopupNotificationWindow:
         gajim.interface.roster.popups_notification_height -= self.window_height
         self.window.destroy()
 
-        if len(gajim.interface.roster.popup_notification_windows) > 0:
+        if len(gajim.interface.roster.popup_notification_windows) > self.index:
             # we want to remove the destroyed window from the list
             gajim.interface.roster.popup_notification_windows.pop(self.index)