Moved close listener to writer