Going into safemode involves stopping the secret manager's thread. An interrupt is sent to this thread. If this occurs while the thread is logging an edit, the resulting exception in the thread will cause the NN to exit.
The fix is to back-port a subset of
HDFS-2579 which went into branch 2 & trunk.