Revised server-side connection closing and added a timeout to waiting for CLOSE frames