Fixed #21255 -- Closed connections after management command ran

Thanks kabakov.as@gmail.com for the report.