Added beforeClose attribute.