fixed onClose clause
see TODO