Fixed problem of crash on close