Delay kserver cleanup until all tasks finish
It might be possible some pending task would run when kserver is already cleaned up. Postpone gsstsig structures cleanup after task and timer managers are destroyed. No pending threads are possible after it.
Make action in maybeshutdown only if doshutdown was not already called. Might be called from getinput event.