The relay timer module described in earlier post can be powered from 6-30V DC which is quite a wide range. Most folks already have such a DC-output wall-wart (9V, 12V, etc.) with a suitable voltage lying around in a junk box. I suppose the cheapest brute-force method is to simply snip off the barrel-coax power plug and expose the DC+ and DC- wires. Or, for most plug styles, there are adapters to convert to solder-less screw-terminal connections.
Note: Most timer modules of this ilk offer a dizzying variety of timing modes. In this example, mode P2.1 was used. The OP parameter is set to 10.0 sec (stopping time). The CL parameter is set to 0.5 sec (delay time). Online listings generally provide the programming instructions and descriptions of operating modes; these are often translations (typically poor) though if you search the web you can find "cleaned-up" translations and youtube how-to videos.
Per your comment about not wanting to deal with AC vs. DC. I get that, but if going the DIY route suggested, all the inexpensive timer modules I've seen require a DC voltage to operate. These are general purpose timer modules that I'm adapting to the arguably quirky-world of O-gauge AC voltage! As others have suggested there are train-specific vendors with off-the-shelf plug-and-play trolley control systems that no doubt hide this "AC vs. DC" nonsense!