Change leave to make tables empty instead of nil

Fix #1830