Make persistKeySync truly synchronous

This makes the `persistKeySync` method use `fs.writeFileSync` so that it's truly synchronous.