Fixed #21255 -- Closed connections after management command ran

Thanks kabakov.as@gmail.com for the report.
OK, but then I think I'd prefer hiding the complexity inside a `ConnectionHandler.close_all` method.