Only free conn if in client context.
The worker_thread_run function will free the conn memory when it quits.
Freeing it in mg_close_connection frees it too early, causing a crash in
the worker_thread_run function as it reuses conn until the server quits
and asks the thread to quit.