Currently recoverLease API will return true if file is already closed. Otherwise it will trigger internalLease recovery and return false. It may take some time to really complete this recovery and file to be closed completely. So, there is noway for the users to wait correctly until file is closed completely.
It would good if we have one API which says whether that file is closed or not. So, that users can relay on that proceed further if and only if file is closed completely.
See the discussion in