OK, I think I found it.
This is what I did:
I removed Main out of the list of autocreate forms, so that only DMOD remains there. I noticed the program really hang here if there was no connection.
I removed
Application.terminate;
in the Exception-parts.This is the code that is below the code I posted before. This is also the code that was still getting executed after
Application.terminate;
was called in the Exception-part. I added an extra check here and call Main also here if everything is good to go.if cnConnect.Connected then begin ADOPermissions.Open; ADOGroupMembers.Open; ADOGroupAccess.Open; ADOGroups.Open; ADOUserAccess.Open; ADOUsers.Open; Application.CreateForm(TfrmMain, frmMain); end else Application.terminate;
Now the process disappears as it should be.
I feel a bit stupid that I have not discovered this myself by using a breakpoint like I did now, but I thought Application.terminate;
would stop and kill the process directly.