Added methods to handle process termination