fixed main loop error, window now exits properly