Fix crash on close