[WIP] Graceful close

Need to think about this more... but if you have any ideas, throw them out.