rem: gDBView.loadMessageByMsgKey(nextMstKey);  
add: if (nextMstKey != -1) { gDBView.loadMessageByMsgKey(nextMstKey); } else { window.close(); } 
context: function HandleDeleteOrMoveMsgCompleted(folder){	dump("In HandleDeleteOrMoveMsgCompleted\n");	var folderResource = folder.QueryInterface(Components.interfaces.nsIRDFResource);	if(!folderResource)		return;	var folderUri = folderResource.Value;	if((folderUri == gCurrentFolderUri) && gCurrentMessageIsDeleted)	{    gCurrentMessageIsDeleted = false;    if (gNextMessageViewIndexAfterDelete != -1)     {      var nextMstKey = gDBView.getKeyAt(gNextMessageViewIndexAfterDelete);      gDBView.loadMessageByMsgKey(nextMstKey);    }    else    {      // close the stand alone window because there are no more messages in the folder      window.close();    }	}}
meta: 9421	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/9421/0d3611ded1fc3e6e209579921fb41cfb235996d2/messageWindow.js/clean/mailnews/base/resources/content/messageWindow.js