Handle client disconnects and some cleanup