Fixed main window closing through menu

& removed some unused code