Hi Z
Sell any stock on, or after, an ex-date (e.g. ex-div, ex-rights or ex-entitlement) and you have already locked in your allocation. It is normally at the close of trading on the night before the ex-date that you must hold it.
Good weekend to you all
cheers