Improve quit message handling. Should result in fewer segfaults.