The EC2-plugin supports negative expiry times. As far as I can tell that's undocumented, I noticed when investigating
Anyway, it's not fully thought out. If the idle time is -5 (minutes) and a node finishes a job at 23:56, then the next idle check fires at 23:57, it will be terminated as idle because it's within 5 minutes of the end of the hourly billing period, even though it's only been idle for 1 minute and is quite likely to have another job come in any second.
For reference, see ec2-plugin/src/main/java/hudson/plugins/ec2/EC2RetentionStrategy.java, _check(...).
I'm not sure what the answer is here. I'm not sure it's right to assume that the node must be both idle for abs minutes and within n minutes of its idle time, but that's the most obvious answer. It'd mean that a setting of 5 would expire a node if it was idle for 5 mins and within 5 mins of billing period end. So if it went idle at 11:54 we'd terminate it at 11:59.
I lean toward that answer in the absence of better ideas. Suggestions?