Disconnecting in a Thread-Safe Environment
If you issue the DISCONNECT statement in a thread-safe application, keep in mind that an active connection can be disconnected only from within the thread in which it is active. Therefore, one thread cannot disconnect the active connection of another thread. The DISCONNECT statement generates an error if such an attempt is made.
Once a connection becomes dormant, however, any other thread can disconnect it unless an ongoing transaction is associated with the dormant connection that was established with the WITH CONCURRENT TRANSACTION clause of CONNECT. If the dormant connection was not established with the WITH CONCURRENT TRANSACTION clause, DISCONNECT generates an error when it tries to disconnect the connection.
For an explanation of connections in a thread-safe application, see SET CONNECTION statement.