Train drivers have voted overwhelmingly to accept a multiyear pay offer, ending a two-year dispute at 16 rail companies.