You can try to use this to exit edit mode if you are using an add in:
Globals.ThisAddIn.Application.SendKeys("{ENTER}");
And I would recommend somthing similar to this this method to determine if Excel is in Edit Mode:
public static void VerifyExcelIsNotInCellEditMode()
{
if (Globals.ThisWorkbook.Application.Interactive)
{
try
{
//Will throw an error if user is editing cell
Globals.ThisWorkbook.Application.Interactive = false;
Globals.ThisWorkbook.Application.Interactive = true;
}
catch
{
throw new Exception("Excel is in Edit Mode.");
}
}
}