Ensure the prompt is always restored, even if the process crashes

Edge case of #41