Handle listen errors and add close() method