Do not close event loop in utility function - handle it only in main(). For this reason, change appropriate functions to coroutines. Fixes QubesOS/qubes-issues#2865
Wrap setting events handling machinery for just this purpose in a single function, to not duplicate it all over the code.