All file handles are now closed when a LotusScript module stops executing, so Sub Terminate doesn't need a "Close" statement.
Terminate can be used for other kinds of cleanup, such as deleting temporary files, but Terminate should be kept as short as possible, because if a module times out during Initialize, Terminate is called and runs to completion. For example, if a module times out after one minute and the module's Terminate runs for two minutes, the total module will run for three minutes.
If a module is halted by control-break, Terminate runs only for a fraction of a second after the control-break, and results are unpredictable.
| Halted by | Initialize() | Terminate() | File handles |
| Normal completion | runs to completion | runs to completion | all close |
| Timeout during Initialize() | stops at timeout | runs to completion | all close |
| Timeout during Terminate() | runs to completion | runs to completion | all close |
| Control-Break during Initialize() | stops at control-break | runs for its first <1 second | all close |
| Control-Break during Terminate() | runs to completion | continues for <1 second | all close |