fixes onexit callback bug