Fix avoid null pointer exception when leaving queue