#3073 Fix write() for session_regenerate_id(TRUE)

Switching the if statements, because destroy() already removed the lock.
Pardon me if I messed up, this is my first commit & pull request ever... :|