Fix background flush bug

When flushInBackground was called in a thread without a running NSRunLoop, the background flush would not get scheduled. This commit makes sure the selector tricks run on the main thread while ensuring the flush still happens on a background thread.