I have no experience, but I can google.
5. Does selling shares affect a distribution?
If you sell the entire stock position two days or more before the dividend-payable date, Your distribution will be paid in cash. If, however, You sell an entire position within the two day time frame of the security’s payable date, the dividend will be reinvested, resulting in additional shares. Selling these subsequent shares will require another sell order, which will incur additional commission charges. Dividends which would have been reinvested into less than one whole share will be automatically liquidated into cash.
I will let you google to find which broker has these policies. Some brokers don't have reinvestment programs, so I would surmise that the OP is not with such a broker.