Corrected a bunch of fucking bugs

Fixed the crash when the window was closed by deleting the UI after
everything else;