Added an on close and on open callback