title: Indy, TidNotify and closing TidTCPServer
body: <p>I have a TidTCPServer which use database manipulating inside onExcecute event (by using TidNotify). Everything works very good instead of possibility closing application. 
  During closing application I do not know whether everything Notify instances finished their work or not and usually I get Runtime Error 216 (I think I close database before "notify" work end).
  Is any way to check - are there waiting old Notify posts or not to be sure I can close application.
  Other question is how to protect TidTCPServer from accepting new connection during closing server process.
  I use code like below but I obtain the error still.</p>
  
  <pre><code>type
    TShutdownThread = class(TThread)
    protected
      procedure Execute; override;
    end;
  
  
  procedure TShutdownThread.Execute;
  begin
    IdTCPServer.Active := false;
  end;
  
  
  //closing...
    if IdTCPServer.Active then
    begin
      with TShutdownThread.Create(false) do
        try
          WaitFor; // internally processes sync requests...
        finally
          Free;
        end;
    end;
  </code></pre>