Hi,
Thank you for the patience.
I did a test with RT1020 EVK board using attached code.
I could regenerate your mentioned issue (debugger lost connection).
While, I can follow this thread mentioned way to recover the board.
First of all, please make sure you set the board SW8 (on the board bottom side) with serial download mode:
1) SW8: 1-OFF,2-OFF,3-OFF,4-ON
2) Power off and power on again, or Press Reset button
Below is my test result:

After that, change SW8 back to 1-OFF,2-OFF,3-ON,4-OFF, then you can debug another project as expected.
Wish it helps.
Mike