Add closeMutex and use it on clean up