fix: set connection to NULL when finishing it

This will avoid CloseConnections() to try to close an already closed connection.
added some more log messages

Now we should be able to distinguish different events more easily