Improve smartclose

closes #2