fixing npe on handleClose