method

at_exit

v1_8_6_287 - Show latest stable - Class: Kernel
at_exit()
public

Converts block to a Proc object (and therefore binds it at the point of call) and registers it for execution when the program exits. If multiple handlers are registered, they are executed in reverse order of registration.

   def do_at_exit(str1)
     at_exit { print str1 }
   end
   at_exit { puts "cruel world" }
   do_at_exit("goodbye ")
   exit

produces:

   goodbye cruel world

1Note

at_exit in sintra

samsam ยท Mar 28, 2010

in main.rb of sinatra:

at_exit { Application.run! if $!.nil? && Application.run? }