Better handling of closing