Fix up some bugs that can happen during zdoor:close/2