To foreclose is to prevent something from happening. If you want to foreclose any possibility of getting in a car accident, you should travel by train instead.
Foreclose comes from the Old French forclore, "exclude or shut out," which led to its sense of "bar from happening," and also the legal meaning, "bar someone from redeeming a mortgage." If a bank forecloses on a property, they take it away from the person who lives there. This typically happens once the homeowner has missed several payments on their mortgage, the money they owe after borrowing from the bank.