public void init() throws Exception {
if (shutdownTask != null) {
ShutdownHooks.remove(shutdownTask);
}
// Register a task to restore the terminal on shutdown
this.shutdownTask = ShutdownHooks.add(new Task()
{
public void run() throws Exception {
restore();
}
});