remove the record if trying to leave the page