end.close() bug fixed