Former Watford, England and Manchester United goalkeeper Ben Foster has announced his retirement from football at the age of 39.