For the vi editor or text window, you simply need to press ‘q’ that can be used to exit
First press Esc button then press ‘q’
If you want to save and exit then you can use press Esc then followed by a colon wq
:wq
This will save your file and exit from the vi editor and windows text.