implemented proper repository shutdown