onClose handles all of close's code