Fixed location of lock file and release of lock in case of error