correctly terminate mode array

we were always clearing mode[2], but mode[1] might be non-zero
in the 'r' or 'w' cases.