Imap.Idle method blocks current thread. In Console example this is the main thread of the app, that's why Imap.StopIdle is invoked from a separate thread).
To stop Idle method you need to invoke Imap.StopIdle method. StopIdle method is thread-safe.
In most scenarios you'll run Idle method on a separate/background thread, in order not to block the main/UI thread.
In such case you can simply invoke StopIdle from the UI thread.