/// <summary>
        /// Closes component and frees used resources.
        /// </summary>
        /// <param name="correlationId">(optional) transaction id to trace execution through call chain.</param>
        public override async Task CloseAsync(string correlationId)
        {
            if (!IsOpen())
            {
                return;
            }

            if (_connection == null)
            {
                throw new InvalidStateException(correlationId, "NO_CONNECTION", "MQTT connection is missing");
            }

            if (_localConnection)
            {
                await _connection.CloseAsync(correlationId);
            }

            _opened = false;

            await base.CloseAsync(correlationId);
        }