iOS crash fix

When the window holding the editor closes, it crashes the app, which is
memory related so this is my attempt at managing memory. Tested with
iPhone simulator and working properly.