Discovered that 'trap' does not work with $CLI on Windows when working #2471 This example shows a workaround.