Someone asked me this question just now and I remembered reading this thread and then realised I forgot to reply to it...
Your keyboard is set to a scheme which includes what's known as "dead keys". If you press the tilde, accent grave, apostrophe, quotation marks or accent circonflexe key, it will not immediately type `, ~, ', " or ^. It will instead hold the character until you press a key again, and then(if possible) combine it with that key. For example, an apostrophe followed by a vowel will result in a vowel with an accent aigu on it, or in the case of the letter C, a C with a cedille(áéíóýúç).
Because of this, if you don't press a vowel after pressing the tilde key, Windows actually tries to "type the accent grave" again(for example, accent grave followed by Q results in `q), which closes your console because it is being registered as you typing another accent grave(but it's actually Windows doing it). My guess as to why it's working in the main menu is because you're pressing a button instead of pressing ` when you open it from the menu.
Possible solutions are: using a keyboard scheme which doesn't have dead keys(yours is probably set to US-International, which does have dead keys in it), changing your console toggle bind to a button which is not one of the five aforementioned characters, or simply typing a vowel and deleting it every time you open the console. Hope that helps.