added onBeforeClose to call onComplete method
build