Close context before writing citations