Tom doesn't get out of the bargain with Old Scratch. Initially, he doesn't agree to it because his wife was interested. Just out of pure stubborness he refuses to deal with Old Scratch. However, after his wife tries to make her own deal and disappears, he makes his agreement with Old Scratch. As he ages and sees death on the horizon,He tries to overcome his agreement by becoming a "violent church goer".
"He prayed loudly and strenuously as if heaven were to be taken by force of lungs." (Paragraph 56)
Tom was as serious in religious matters as he was in money matters. The problem was that he didn't live his religious convictions. He still was a lender who was heartless and took people's money.
He also became a fervent Bible reader.
"That he might not be taken unawares, therefore, it is said he always carried a small bible in his coat pocket". (paragraph 57)
He also kept one in his desk and could be found reading it often, just before he did business.
An old wives' tale said that he had new horseshoes put on his horse, put a saddle and bridle on it, and had it buried upside down, with its feet in the air. This was because he thought that the world would be turned upside down on the last day, and he would be able to outrun the devil. However, this story was not confirmed. It was an old wives' tale. Washington Irving tells us that
"If he really did take such a precaution it was totally superfluous.." (paragraph 58)
.... which means that it really wouldn't matter, it would be a waste of his time.
In the end, nothing he did got him out of his deal with Old Scratch.