diff --git a/ChangeLog b/ChangeLog
index 3e4509b9abe2a51e3e856154e197ad65f45913d9..f51ed4d25345d4e8a446ec7221f2bdb641ecb885 100755
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2005-11-11  Kevin P. Fleming  <kpfleming@digium.com>
+
+	* apps/app_voicemail.c (close_mailbox): properly remove deleted messages at mailbox close time (issue #5663)
+
 2005-11-11  Mark Spencer <markster@digium.com>
 
 	* channels/chan_zap.c (zt_bridge): only enable/disable DTMF detection on SUB_REAL channels
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index b30d69df8dd2b61b5759567f9bb6423bf84e6c5a..b4b77c71d487f87b8233e3ae9f1da6ee67e0dae4 100755
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -3869,7 +3869,7 @@ static int open_mailbox(struct vm_state *vms, struct ast_vm_user *vmu,int box)
 
 static int close_mailbox(struct vm_state *vms, struct ast_vm_user *vmu)
 {
-	int x;
+	int x, nummsg;
 	int res = 0;
 
 	if (vms->lastmsg <= -1)
@@ -3902,12 +3902,14 @@ static int close_mailbox(struct vm_state *vms, struct ast_vm_user *vmu)
 			} 
 		} 
 	} 
-	for (x = vms->curmsg + 1; x <= vmu->maxmsg; x++) { 
-		make_file(vms->fn, sizeof(vms->fn), vms->curdir, x); 
-		if (!EXISTS(vms->curdir, x, vms->fn, NULL)) 
-			break;
-		DELETE(vms->curdir, x, vms->fn);
-	} 
+
+	/* Delete ALL remaining messages */
+	nummsg = x;
+	for (x = vms->curmsg + 1; x <= nummsg; x++) {
+		make_file(vms->fn, sizeof(vms->fn), vms->curdir, x);
+		if (EXISTS(vms->curdir, x, vms->fn, NULL))
+			DELETE(vms->curdir, x, vms->fn);
+	}
 	ast_unlock_path(vms->curdir);
 
 done: