const CLEANUP_EVENTS = [ 'SIGINT' , 'exit' , 'uncaughtException' , 'unhandledRejection' ] ; export class Manager { private cleaned = false ; constructor ( ) { const cleanup = ( ) => this . cleanup ( ) ; CLEANUP_EVENTS . forEach ( ( ev ) => process . on ( ev , cleanup ) ) ; } public cleanup ( ) { if ( this . _cleanup && ! this . cleaned ) { this . cleaned = true ; this . _cleanup ( ) ; } } protected _cleanup ? ( ) ; }