flush replies when entering an eventloop

avoids possible hangs when the GUI eventloop prevents queued replies from being sent

should close #4997