The terminal is closed in the `finally` section.