onclose implementation is now optional