add closing functionality