OnCloseQuery
  if (...) then
    CanClose = false;