#main $obj = DBConnect->new ; $SIG{INT} = \&close ; .... .... sub close { $obj->close ; exit ; }