Add 'beforeClose' option.