fix second close on shutdown