Avoid queueing recorder code never exiting if events remain queued and mysql connection is made but never completes.

This introduces an EventWriteTimeoutOnStop parameter that controls how long we wait on at least one event to be written when the recorder stops.
If this is breached, then remaining in-memory events are discarded and shutdown proceeds as normal.
This is present as a config parameter but should normally never need to be changed.