Bonjour, TouEnMasm!
For the normal completion of the Windows program, it is enough to process the WM_DESTROY message
WndProc proc hWin:QWORD,uMsg:QWORD,wParam:QWORD,lParam:QWORD
mov hWin,rcx
cmp edx,WM_CREATE
je wmCREATE
cmp edx,WM_SIZE
je wmSIZE
cmp edx,WM_PAINT
je wmPAINT
cmp edx,WM_DESTROY
je wmDESTROY
cmp edx,WM_KEYDOWN
je wmKEYDOWN
cmp edx,WM_TIMER
je wmTIMER
leave
jmp NtdllDefWindowProc_
wmDESTROY::invoke wglMakeCurrent,0,0
invoke wglDeleteContext,hRC
invoke ReleaseDC,hWin,hDC
invoke KillTimer,hWin,10
invoke RtlExitUserProcess,NULL; <----