If you need to release some of your objects before shutdown and want to call StopListen before doing so, write a loop to wait for "Server.TotalConnectionCount=0", like ...
repeat
Sleep(10);
Application.ProcessMessages;
until Server.TotalConnectionCount=0;
Best Regards,
Danijel Tkalcec