Fix exit twice and msg queue can not delete
Add timeout support