Prevent script from writing before termination