I haven't been able to reproduce this issue you are having. The Outlook process does take a little longer to end but it does end.
That being said, there are better ways to close down these processes. As said in my comment, have a look at this answer which links to Siddharth Rout's bit of code.
First you would need to declare xlApp
and olApp
at class level. You would also need add the following method into your code:
Private Sub ReleaseObject(ByVal obj As Object)
Try
Dim intRel As Integer = 0
Do
intRel = System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
Loop While intRel > 0
obj = Nothing
Catch ex As Exception
obj = Nothing
Finally
GC.Collect()
End Try
End Sub
You can then call this method when you are closing down your form:
Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
xlApp.Quit()
ReleaseObject(xlApp)
olApp.Quit()
ReleaseObject(olApp)
End Sub
Overall your code would look something similar to this:
Public Class Form1
Private xlApp As Excel.Application
Private olApp As Outlook.Application
Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
'Open new EXCEL.EXE in the Task Manager
xlApp = New Excel.Application
'Open new OUTLOOK.EXE in the Task Manager
olApp = New Outlook.Application
End Sub
Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
xlApp.Quit()
ReleaseObject(xlApp)
olApp.Quit()
ReleaseObject(olApp)
End Sub
Private Sub ReleaseObject(ByVal obj As Object)
Try
Dim intRel As Integer = 0
Do
intRel = System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
Loop While intRel > 0
obj = Nothing
Catch ex As Exception
obj = Nothing
Finally
GC.Collect()
End Try
End Sub
End Class