FYI, putting session_write_close() at the very end of script execution is useless - CI will do that on its own at that point.
If you do use it, it has to be at a point where you no longer need to read/write new session data, but more code is to be executed - thus, the lock is freed as soon as necessary while the rest of your code still executes.