Adding missing unlockWrite when toggling debug mode.