using System.Runtime.IteropServices;
[DllImport("User32.dll",CharSet = CharSet.Auto)]
public static extern int GetWindowThreadProcessID(IntPtr hwnd,out int ID)
public void closeProcess()
{
Excel.Application ExcelApplication = new Excel.ApplicationClass();
IntPtr hwnd = new IntPtr(ActiveApplication.Hwnd);
int ID = 0;
GetWindowThreadProcessID(hwnd,ID);
System.Diagnostics.Process my = System.Diagnostics.Process.GetProcessById(ID);
my.kill();
ExcelApplication = null;
}