Fix chanopts not saving if /quit before exit

This is the C fix, unfortunately a proper fix, e.g.
 removing the dependency on session_name all together is a much vaster
 refactor outside the scope of this bugfix.

Closes #1111