I don't tend to use the keyboard to play the game so not sure about this one. In the Unit Design screen, if you hit ESC, what gets closed is the training units menu of the city that you can see behind the Unit Design window.

Surely not very important but I'd understand that hitting ESC I should be cancelling the Unit Design menu. 