i think it's not really much that you can do there... you could've considered folding the river... but he played it just like a missed draw... I don't know I would've probably folded the river cause he put you in the situation where you gotta think.. it's either the nuts, or nothing... it's totally fine that you called there considering the situation but it's really hard for me to tell what I would've done since I don't know how he plays.
facing a 40bb river bet when you've invested 14bb into the pot... I'd fold. Save the chips, find a better spot. Only hand you beat is naked AcX bluffs. No way someone potsize bets the river with just a pair of 9x.