When pressing M the spell casting window comes up and pressing ESC dismisses it.
Pressing M more than once, however, causes multiple stacked versions of the window which require hitting ESC the same number of times to dismiss.
To Reproduce:
1) Hit M to bring up spell window
2) Hit M twice more
3) Press ESC once, notice that spell window is still there
4) Press ESC twice more to dismiss overlapped windows
The correct behaviour for pressing M again after the spell window is already up is to dismiss the window. This is standard behaviour on virtually ALL games. ie Press M once to bring up window, press either ESC or M again to dismiss.