fixes application not closing properly