Thank you for finding this. We confirm there is a bug here.
Our fix is to move the 'ENV_LEAVE' just after the call of the '__file_handle_cleanup' .
If you need a formal patch, please send a mail to me with the version. My address is email@example.com
Winter, Oracle Berkeley DB