Fix various replay queue wedges
This fixes a couple of cases where the ReplayQueue drops operations when it shouldn't:
- When the queue is closing and being flushed, allow remote ops to obtain a remote session
- When a connection has been disconnected and cancelled commands that can be retried are actually retried
The should fix things like email flags changes not being applied on folder close (in case of the former), or a connection has gone bad and has to be re-established (in case of the latter), and other issues like frequent "Message not saved" messages (see #385 (closed)) and message bodies not being loaded (#215 (closed)) at least.