fix nullref on quit
Add locking to the session on RepoBase