Fixed some queries not being processed after shutdown