close layouts properly