Fidelity Investments is closing its Marlborough office and moving as many as 1,000 jobs out of Massachusetts, the company confirmed Tuesday.