added code to stop iLock gracefully