Fix potential SQL queue shutdown error.